Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

Unable to start SQL Server service using VB.NET winforms - 'Cannot open MSSQLSERVER service on computer '

$
0
0

In my application events class startup, I check to see if the SQLSERVER service is running, if not then I would like to start the service. I have found some code that checks that status and then starts the service, but I keep getting an error message 'Cannot open MSSQLSERVER service on computer '.'. I've verified the Service Name in the properties window and even tried the display name with no luck. Googling keeps going back to check status and then start service. Here is the code:

Dim service As New ServiceController("MSSQLSERVER")

If service.Status = ServiceControllerStatus.Stopped Or service.Status = ServiceControllerStatus.Paused Then
        Try
            service.Start()
        Catch ex As Exception
            MsgBox("StartService error: " & ex.Message)
        End Try
End If

Could I missing a reference?

Any help is much appreciated, thanks.


William


Viewing all articles
Browse latest Browse all 12583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>