Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How I detect fast if an MSSQL server is running?

Status
Not open for further replies.

szmgg

Programmer
Nov 29, 2003
8
0
0
HU
How I detect fast if an MSSQL server is running?
My present solution is this:

Code:
dim conn as New SQLClient.SQLConnection("blabla;Connect Timeout=2;blabla2")
dim running as boolean
try
   conn.open
   running = True
catch ex as Exception
   running = False
end try
...

But it's slow. (Slower then 2 seconds, maybe 10-15 sec)

Do you know a method to do this faster?
Any help would be appriciated.

Máté
 
Yes, that will be very slow as you shouldn't use Try/Catch blocks to direct the flow of the application.

There's quite a few ways to determine which servers are available; one of which is outlined in faq796-6142


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Thanks!

I use SQL 2000, so I write the final solution to this:
First add reference "SQLDMO" (it's a COM)
Then:
Code:
Dim s As New SQLDMO.SQLServerClass
s.Name = "blabla"  'SQLServer host
running = (s.Status=SQLDMO.SQLDMO_SVCSTATUS_TYPE.SQLDMOSvc_Running)

Thanks again

Máté
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top