Hello all, I am hoping this is the correct place for this. I have an application that depends on an active connection to Sql Server Express 2005. I am looking for a way is any to check for the existance ofthe server I defined and wether it is online or not. I know I can just catch the error on connection but it takes a bit and I have customers trying to cancel it before it's finished because they think it's locked up. I would like a quick way to check without trying to create a connection if it's online, then if it is, proceed, if not, let the customer know. I was hoping for something like a database server ping of sorts.
Thank you,
Jim
Still, the best/reliable way to check whether you can reach the server instance is connect to it. If you think the lock up time is too long considering that the server is down, you can adjust the connection timeout to be smaller than on-default value. There is caveat to this approach if your target machine is unreachable in the network, which may cause a single physical operation, tcp connection to take long time to finish.
Another way on top of my head is to check service manager of your targeted machine using console commmand "SC" and check the server status, an example is the following. The
>sc \\servername query mssqlserver
SERVICE_NAME: mssqlserver
TYPE : 10 WIN32_OWN_PROCESS
STATE : 4 RUNNING
(STOPPABLE, PAUSABLE, ACCEPTS_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x0
-HTH
No comments:
Post a Comment