Information générale
Catégorie:
Bases de données DAO/RDO/ODBC/ADO
Hi David,
You can install the sample program from your MS SQL Server 2000 CD.
To install it, put the CD on the CD Drive and click the autorun.exe.
On the "Install selection" window choose "Upgrade, remove, or add components to an existing Instance of SQL Server" option. On "Existing Installation" window select "Add components to your existing installation" then click next button. On the "Select components" window, locate the "Code Samples" from "Components" box and mark the check box. Continue the steps until you complete the installation.
The code in the sample is like the following:
Note that you need to add a reference to "Microsoft SQLDMO Object Library" to run this code.
Dim oSQLServerDMOApp As SQLDMO.Application
Dim oSQLServer As SQLDMO.SQLServer
Set oSQLServerDMOApp = New SQLDMO.Application
'Look for the registered server groups
Dim oServerGroup As SQLDMO.ServerGroup
For Each oServerGroup In oSQLServerDMOApp.ServerGroups
debug.print oServerGroup.Name
Next
'Check on server status
If oSQLServer.Status = SQLDMOSvc_Paused Then
'if paused then continue
oSQLServer.Continue
Else
'else start the server
oSQLServer.Start False, "Your_SQL_Server_Name"
End If
'To Stop SQL Server
'Check on server status
If oSQLServer.Status = SQLDMOSvc_Running Then
'stop the server
oSQLServer.Stop
End If
Note that this code is not tested this will run successfully.
But this is the idea on how to manage SQL Server services.
It is better if you can install the sample code from SQL Server 2000 D.
Hope this help.
Précédent
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement