Stopping SQLExpress service
I am using the following line to create a serviceControllerSQL type.
Code:
ServiceController serviceControllerSQL = new ServiceController("MSSQLSERVER");
I then check to see if the service is running and if so close it down.
My question is :
What happens if SQLExpress 2005 and SQLServer 2000 are running on the same machine. How can I just choose the Express service to stop ?
When I look at the services running on my machine I can only find MSSQLSERVER.
Re: Stopping SQLExpress service
I think the service name of SQLExpress 2005 is SQLEXPRESS. Use this instead of MSSQLSERVER.
Re: Stopping SQLExpress service
I cannot see SQLEXPRESS antwhere in my list of services. However I can find a "SQL Server (SQLEXPRESS)" entry.
"SQL Server (SQLEXPRESS)" doesnt look to me like an appropriate handle for this.
Most unusual.
Re: Stopping SQLExpress service
It's easy enough to get a list of the services on your machine with the ServiceController.GetServices method. You can use that in your app or you can just use it during development to determine the name of the service you want to target.
Re: Stopping SQLExpress service
I was just googling about this and came across this knowledge base article. That article basically detects the status of the SQL Server Express service. They are using MSSQL$SQLEXPRESS as the service name.