Q1 How can I get the sql server/msde running status?Running/Stopping/Stopped/...?
Q2 And how can I know whether a specified database is currently in use?
A1 On NT 3.x, 4.x, Win 2k, XP, and later one may poll for a list of currently running services e.g.(Net start). On Win Me, 9x and below generally there is not a service implementation per se (generally one would need to poll running processes).
A2 One may check the dbname column of the result set returned by:
Originally posted by rnealejr
You can use the SQL-SCM api (however, conflicting documentation exists that it does not work for 2000 even though it is documentated with 2000). Also, you can use the scm.exe utility.
thank you for your reply
My database is MSDE, I want to find some API that can work under both 2000 and 98.Could you please tell me the API and dll?(I don't want DMO or WMI).I can know SQLServer whether is running through scm -action 3. But how can I get return state in program?
Scm.exe (and the related API) should be easier and more direct to use to ascertain the DBMS operational state. For some reason, I didn't think about the service control manager, (I'm not sure scm supports Sql Server 6.x and earlier installs, but that is not an issue using MSDE).