Click here to Skip to main content
16,023,103 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Everybody,

I want to stop and start a SQL Server 2005 sevice with C#.Net 2005.
Because I want to copy A database In Sql to my file.
If SQL Service is started I Cannot copy the database.
Please help me.

Thanks in advance.
Posted
Updated 25-Mar-10 6:34am
v2

ServiceController service = new ServiceController(serviceName);
service.Stop();
service.WaitForStatus(ServiceControllerStatus.Stopped, timeout);
service.Start();
service.WaitForStatus(ServiceControllerStatus.Running, timeout);
 
Share this answer
 
 
Share this answer
 

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