How to check if the connection to a remote computer exist

  • Thread starter Thread starter Chin Chien Ping
  • Start date Start date
C

Chin Chien Ping

Hi,

I looking for a solution for how to check if a connection to a remote
computer exist or not using vb.net.

I 'm writing a program which will request data from a remote sql server. I
need to check if the connection to the remote server exist, before open the
connection or run the the sql command.

Pls helps, urgent.

Thanks,
Chin
 
Hello Chin,

I'd try to open the connection. If exception occurs, that means the connection
to the SQL Server can't be established.
 
I have tried this method.

However, this will coz my system hang, and I only knew the connection does
not exist until the connection timeout.

Is there any better solution ?

Thanks,
Chin
 
I really don't think there is any other solution. When you say "system
hang", does that mean your UI hangs? If that's the case, I'd spawn off a
thread to let it do check connection checking and let it raise an event
to see if the connection succeeded or not. That way, your UI won't hang.
 
Back
Top