[Message Deleted]
-
Probably: System.Diagnostics.Process.Start("NET STOP MSSQLSERVER"); System.Diagnostics.Process.Start("NET START MSSQLSERVER");
Upcoming Scottish Developers events: * Glasgow: Tell us what you want to see in 2007 My: Website | Blog | Photos
-
You can also use the ServiceController[^] class.
Using the GridView is like trying to explain to someone else how to move a third person's hands in order to tie your shoelaces for you. -Chris Maunder
-
Probably: System.Diagnostics.Process.Start("NET STOP MSSQLSERVER"); System.Diagnostics.Process.Start("NET START MSSQLSERVER");
Upcoming Scottish Developers events: * Glasgow: Tell us what you want to see in 2007 My: Website | Blog | Photos
You can't do it that way, with Process.Start(" ~ DOS NET START/STOP ~ "); You have to do it like this (assuming SQL Server is running on the same computer as your program): string localComputer = Environment.MachineName.ToString(); // Stop MSSQLSERVER ServiceController controller = new ServiceController(); controller.MachineName = localComputer; controller.ServiceName = "MSSQLSERVER"; string status = controller.Status.ToString(); if (status == "Running") { // Stop the service controller.Stop(); Console.WriteLine("MSSQLSERVER has been stopped."); } // Start MSSQLSERVER controller.MachineName = localComputer; controller.ServiceName = "MSSQLSERVER"; status = controller.Status.ToString(); if (status == "Stopped") { // Stop the service controller.Start(); Console.WriteLine("MSSQLSERVER has been started."); } Also, make sure the service name is MSSQLSERVER in the Services console (Start -> Run -> services.msc). On named instances, this is not always the case. -Tom