Lan连接状态类 [英] Lan connection status class

查看:71
本文介绍了Lan连接状态类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI全部,



我有基于LAN的应用程序与远程SQL服务器连接,因此我想检查是否有LAN网络可用于执行插件数据更新等事件或者从远程服务器中选择或者在没有LAN连接的情况下发生错误



i尝试使用

HI All,

I have LAN based application connected with remote SQL server, therefore i want to check is LAN network is available to execute event like insert data update or select from remote server or otherwise it will occur error without LAN connectivity

i have try with

System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable()

它会很好用,但我的应用程序有很多事件要用远程服务器执行,所以我需要将上面的代码应用到它们的每一个像



it will working great but my application has lot of events to execute with remote server, so i need to apply above code to every single of them like

if(System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable() == true)
{

//execute command...................... there are thousand of them....
}

else
{
MessageBox.Show("NO LAN Available");
return;
}







所以我想要小班教学与我目前的表格分开可以做以下事情的课程

01.实时局域网连接检查和弹出按摩盒给用户,如果局域网不可用这个按摩盒不会移除,直到局域网再次生效,程序无法工作,直到局域网回到生活。喜欢使用ShowDialog打开表单(这个);



请帮我这个!



谢谢!



SHOUTING删除 - OriginalGriff [/ edit]




SO I want small class for doing this separately from my current forms and classes that can do following things
01. real time LAN connection check and popup massage box to user, if LAN not Available this massage box not remove until LAN live again and the program not working until LAN back to live. like form open using ShowDialog(this);

Help me on this!

Thanks!

[edit]SHOUTING removed - OriginalGriff[/edit]

推荐答案

如果我理解你,你想要对你网络中的MS SQL服务器数据库执行许多命令。



在我看来你不需要检查LAN是否可用,因为,当你尝试连接到你的SQL服务器(放在局域网中),程序会显示一条消息错误,该服务器不可用。



使用 SQLConnection类 [ ^ ]。使用以下命令创建与sql数据库的新连接并捕获错误: Try..Catch ...最后。 ..试试 [ ^ ]阻止。

你可以设置很多 SQLConnection类属性 [ ^ ],如: connectiontimeout [ ^ ]





更多:

如何创建连接到SQL Server数据库 [ ^ ]?

检测Internet网络可用性 [ ^ ]

网络连接检测C# [ ^ ]
If i understand you well, you want to execute many commands to MS SQL server database located in your network.

In my opinion you don''t need to check if LAN is available, because, when you try to connect to your SQL server (placed in LAN), program will show you a message error, that server is not available.

Use SQLConnection class[^]. to create new connection to your sql database and catch errors using: Try..Catch ...Finally...End Try[^] block.
You can set up many of SQLConnection class properties[^], like: connectiontimeout[^]


More:
How to create Connections to SQL Server Databases[^]?
Detect Internet Network Availability[^]
Network Connection Detection C#[^]


这篇关于Lan连接状态类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆