Click here to Skip to main content
15,887,430 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Cannot open MSSQLSSQLEXPRESS service on computer'.'.


What I have tried:

Dim myController As New System.ServiceProcess.ServiceController("SQL Server (SQLEXPRESS)")

---------------------------------------------------------------------------------
VB
Private Sub Service_status()

        If myController.Status = ServiceProcess.ServiceControllerStatus.Running Then
            TextBox1.Text = "Started"
        ElseIf myController.Status = ServiceProcess.ServiceControllerStatus.Stopped Then
            TextBox1.Text = "Stopped"
        End If
    End Sub

----------------------------------------------------------------------------------
VB
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Service_status()
    End Sub

-----------------------------------------------------------------------------------
VB
Private Sub BtnStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnStop.Click
        ProgressBar1.Value = 0
        Try
            myController.Stop()
        Catch ex As Exception
            MsgBox(ex.Message)
        Finally
            ProgressBar1.Value = 100
            myController.WaitForStatus(ServiceProcess.ServiceControllerStatus.Stopped) '//Add
            Service_status()
        End Try
    End Sub

---------------------------------------------------------------------------------------
VB
Private Sub BtnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnStart.Click
        ProgressBar1.Value = 0
        Try
            myController.Start()
        Catch ex As Exception
            MsgBox(ex.Message)
        Finally
            ProgressBar1.Value = 100
            myController.WaitForStatus(ServiceProcess.ServiceControllerStatus.Running) '//Add
            Service_status()
        End Try
    End Sub
Posted
Updated 31-Mar-19 5:41am
v2

1 solution

That's probably because the service name is actually "MSSQL$SQLEXPRESS", and not "SQL Server (SQLEXPRESS)". What you used is the Display Name, not the Service name.
 
Share this answer
 
Comments
Jayanta Modak 1-Apr-19 21:19pm    
thanks sir for reply, i try this solution but problem is same , same error massage show please help me
Dave Kreskowiak 1-Apr-19 22:57pm    
Then you have to find the actual service name. Go into the Services manager and find your instance of SQL Server Express. Right-click the service and click Properties. The service name is going to be the first line in the dialog under the tabs.
Jayanta Modak 2-Apr-19 5:23am    
Thanks sir for reply problem is solve i just change to things 1) SQL Server (SQLEXPRESS) TO MSSQLSSERVER
2) and change app.manifest <requestedexecutionlevel level="asInvoker" uiaccess="false">
to
<requestedexecutionlevel level="requireAdministrator" uiaccess="false">

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900