Click here to Skip to main content
15,889,840 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
i write this code in button on click event .

C#
ServiceController controller = new ServiceController();

        controller.MachineName = ".";
        controller.ServiceName = "MSSQLSERVER2008";


        controller.Stop(); 

But i get a error. Cannot open MSSQLSERVER2008 service on computer '.'. How i solved that?
Posted
Updated 10-Jul-14 21:00pm
v2
Comments
ZurdoDev 10-Jul-14 14:08pm    
Either the service does not exist or you don't have permissions to start it.
Maciej Los 10-Jul-14 16:19pm    
Please, provide more details about your issue, especially what you want to achieve. Do you want to start MS SQL server services this way? Do you want to run MS SQL Server instance?
Prasad Avunoori 11-Jul-14 3:22am    
You dont have permission to that perhaps.
ArunRajendra 11-Jul-14 3:34am    
Try replacing "." with full name

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900