Link to home
Start Free TrialLog in
Avatar of crestsolutions
crestsolutions

asked on

Monitoring SQL Server 2000

Hello,

I need to write a VB.NET class that checks to see if SQL Server is running on the machine. This class will be mul-threaded and check every 30 seconds ( approx ) . The easiest way of doing this i suppose is to repeatedly attempt to open a connection and then close it.  Or would it be better to open a single connection and then check the stage of the connection every 30 seconds ?

Is there a more eligent way of doing this.

Thanks.
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

WHY do you want to write an application that checks if SQL Server is running?
Avatar of crestsolutions
crestsolutions

ASKER


Just a simple monitor class for a bigger app which will be sending off emails, alerting users etc if SQL stops running. I'd like to know as soon as possible if SQL is not running, not find out when I attempt to connect and insert data .

Failed to mention in the above  - SQL Server will not be running on the same machine as the app.
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

I've codes a simply method to run in a thread. The method creates a new SQLConnection and opens it. I then check the state before return true of false.

The problem is if i run my app the connection will open as expected. If stop sql server service the connection still opens.

The only time the connection will not open is when i stop the sql server service before running my app.

any ideas ?

thanks
How many users would you have at most?  Open/closing a connection every 30 seconds could produce a condition where you run out of connections quickly if you have a lot of users at one time.

Bob
There will only be 4 users so connections will not be an issue.

Got around that connection issue above by actually executing an empty stored procedure. The sqlCommand object throws an exception is the databsae is stopped even though the connection.state says it is open.