December 19, 2005 at 1:09 am
Hi !!!
I am connecting to SQL SERVER with following VB code :-
Set SQLInstance = New SQLDMO.SQLServer
' Log in
SQLInstance.LoginSecure = True
SQLInstance.Connect "serverName","userid","pwd"
This code works proprerly if the server is already on,but if server is off I get error
Can anyone suggest any method to detect whether Server is on or off.
Thanx
SP
December 20, 2005 at 11:04 am
Couple ideas:
Use a try-catch block to catch a failed Connect call. You should probably set a reasonable LoginTimeout value first.
I believe you could use SQLInstance.Status to check whether the service is actually responding. Again you may need a try-catch block to catch a service unreachable error.
JR
December 21, 2005 at 12:30 am
Can u give me VB code for try catch block??
I am still finding the solution for my prob.
thanx
SP
December 21, 2005 at 5:43 am
this can work for vb.net
Try
[ tryStatements ]
[ Catch [ exception [ As type ] ] [ When expression ]
[ catchStatements ] ]
[ Exit Try ]
...
[ Finally
[ finallyStatements ] ]
End Try
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply