I am writing a test class. In this class, I need to stop the sql server in Setup() method, and restart the sql server in Teardown() method. I don't know how to stop or start the sql server in c#. anyone can help me ?
thx in advance~
I am writing a test class. In this class, I need to stop the sql server in Setup() method, and restart the sql server in Teardown() method. I don't know how to stop or start the sql server in c#. anyone can help me ?
thx in advance~
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Blocked AccountRank #403 · 6.2K reputationPosted Jan 7, 2008, 8:52 PM EST
First u have to add the reference of the System.ServiceProcess.dll and after that create the object of the ServiceController like this:
ServiceController objServiceController = new ServiceController("MSSQLSERVER");
For start the server write this:
objServiceController.Start();
For stop the server write this:
objServiceController.Stop();
surendra kumar9 reputationPosted Jan 7, 2008, 9:26 PM EST