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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find if SQL server is running local...

Status
Not open for further replies.

sachiel

Programmer
Jan 17, 2002
7
0
0
I can get a list of the servers on an NT network using the:

Private Declare Function NetServerEnum Lib "netapi32"

That is dandy, but this does not pick up the (local) server that I have seen in many other dropdowns. The problem comes in the form of a notebook.

Connected to the network, the VB frontend will pickup all of the servers that are advertising on the network, including the local as the computer's name, ie. MYCOMP. If the network is disconnected, no servers will be detected, not even the MYCOMP server. How do I detect if the there is infact a SQL server running locally without using the NetServerEnum function?

I am using VB 6, Win 2k, and SQL Server 7 / MSDE btw. My netlib is multiprotocal. Using ADO.
 
Either you can try and connect to the local SQLServer and if you cannot connect then it probably is not running.

Or you could search for the process "sqlseevr.exe" using win API calls. If the process exists, then SQLServer must be running.

Hope this helps,


Chris Dukes
 
Btw, I am using WMI to check the active processes for a name = "sqlservr.exe" I just discovered WMI today, what a badass replacement for API's....

Do a search for WMI on msdn.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top