Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Opening an SQL server from VB
Message
From
11/07/2003 21:16:26
Rene Lovino
Bigfoot Global Solutions, Inc
Cebu, Philippines
 
 
To
11/07/2003 08:40:45
David Brunelle
Université de Sherbrooke
Sherbrooke, Quebec, Canada
General information
Forum:
Visual Basic
Category:
Database DAO/RDO/ODBC/ADO
Miscellaneous
Thread ID:
00808894
Message ID:
00809496
Views:
28
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.
Previous
Reply
Map
View

Click here to load this message in the networking platform