Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Stop Start Sql server2000

wajahatwajahat Member Posts: 24
how to STOP and START SQL Server Services Manager; mean how to STOP and START SQL Server 2000 engine by using VB6

Comments

  • ShanooShanoo Member Posts: 32
    Hi,

    Add SQLDMO in references and try the code below:

    Dim Srv As SQLServer

    Private Sub cmdStop_Click()
    On Error Resume Next
    '
    Srv.LoginSecure = True
    Srv.Connect "MyServer"
    '

    '
    ' Srv.Connect "MyServer", "MyLogin", "MyPassword"
    '
    Srv.Shutdown
    Srv.DisConnect
    If Err.Number = -2147215802 Then
    MsgBox "SQL Server service stopped successfully.", vbExclamation, "SQL Server stopped"
    Err.Clear
    End If
    End Sub

    Private Sub cmdStart_Click()
    Srv.Name = "MyServer"
    Srv.Start False
    End Sub

    Private Sub Form_Load()
    Set Srv = New SQLServer
    End Sub


    Note: The error handling in the subroutine for stopping SQL Server is compulsory because SQLDMO throws the information of stopping the SQL Server service as an error.

    - HTH
Sign In or Register to comment.