I am using SQL Server 2012 Developer edition and Visual Studio 2013
I get the error message that the application can't start the service on my computer.
I've also tried running a .bat file containing NET START Servicename as a shell; it runs but doesn't start the services
My MSSQLSERVER and SQL Server Agent services are set to start Automatically, but they don't alsway start, which is why I want to test their status, and then start them if necessary.
Has anyone any ideas how to resolve this problem
Code:
Imports System.ServiceProcess (also included in project.references) Dim service As New ServiceController("MSSQLSERVER") ' For checking status of SQL Server & starting if necessary 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
I've also tried running a .bat file containing NET START Servicename as a shell; it runs but doesn't start the services
My MSSQLSERVER and SQL Server Agent services are set to start Automatically, but they don't alsway start, which is why I want to test their status, and then start them if necessary.
Has anyone any ideas how to resolve this problem
Comment