Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. [Message Deleted]

[Message Deleted]

Scheduled Pinned Locked Moved C#
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    R_L_H
    wrote on last edited by
    #1

    [Message Deleted]

    C A 2 Replies Last reply
    0
    • R R_L_H

      [Message Deleted]

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      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

      N 1 Reply Last reply
      0
      • R R_L_H

        [Message Deleted]

        A Offline
        A Offline
        Andy Brummer
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • C Colin Angus Mackay

          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

          N Offline
          N Offline
          navyjax2
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups