DMO Registered Servers...
I am iterating through DMO's registered servers and I want to detect whether a particular server is running ie the service has started...bearing in mind that some of these are on remote machines.... How can I do this through DMO or do I have to use the API? Below is what I have so far...
VB Code:
Dim oSQLApp As New SQLDMO.Application
Private Sub Command1_Click()
Dim oServer As New SQLDMO.RegisteredServer
Dim oServerGroup As New SQLDMO.ServerGroup
Dim oServerSubGroup As New SQLDMO.ServerGroup
Dim oDatabase As New SQLDMO.Database
For Each oServerGroup In oSQLApp.ServerGroups
With tvwMain
.Nodes.Add , , oServerGroup.Name, oServerGroup.Name
For Each oServer In oServerGroup.RegisteredServers
.Nodes.Add oServerGroup.Name, tvwChild, oServerGroup.Name & "\" & oServer.Name, oServer.Name
Next
End With
Next
End Sub
Private Sub tvwMain_NodeClick(ByVal Node As MSComctlLib.Node)
Dim oSQLServer As New SQLDMO.SQLServer
Dim oDatabase As New SQLDMO.Database
Dim oTable As New SQLDMO.Table
If Node.Parent Is Nothing Then
Exit Sub
End If
If Node.Parent = "SQL Server Group" Then
oSQLServer.Connect Node.Text, "poo", "plop"
Else
Exit Sub
End If
For Each oDatabase In oSQLServer.Databases
With tvwMain
.Nodes.Add Node.Key, tvwChild, Node.Key & "\" & oDatabase.Name, oDatabase.Name
For Each oTable In oDatabase.Tables
.Nodes.Add Node.Key & "\" & oDatabase.Name, tvwChild, Node.Key & "\" & oDatabase.Name & "\" & oTable.Name, oTable.Name
Next
End With
Next
End Sub