Results 1 to 2 of 2

Thread: DMO Registered Servers...

  1. #1

    Thread Starter
    Hyperactive Member gravyboy's Avatar
    Join Date
    Jan 2000
    Location
    Where I was before . . . if you don't know then you're new!
    Posts
    334

    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:
    1. Dim oSQLApp As New SQLDMO.Application
    2.  
    3.  
    4. Private Sub Command1_Click()
    5.  
    6. Dim oServer As New SQLDMO.RegisteredServer
    7. Dim oServerGroup As New SQLDMO.ServerGroup
    8. Dim oServerSubGroup As New SQLDMO.ServerGroup
    9. Dim oDatabase As New SQLDMO.Database
    10.  
    11.     For Each oServerGroup In oSQLApp.ServerGroups
    12.         With tvwMain
    13.             .Nodes.Add , , oServerGroup.Name, oServerGroup.Name
    14.             For Each oServer In oServerGroup.RegisteredServers
    15.                 .Nodes.Add oServerGroup.Name, tvwChild, oServerGroup.Name & "\" & oServer.Name, oServer.Name
    16.             Next
    17.         End With
    18.        
    19.     Next
    20.    
    21. End Sub
    22.  
    23.  
    24. Private Sub tvwMain_NodeClick(ByVal Node As MSComctlLib.Node)
    25.  
    26. Dim oSQLServer As New SQLDMO.SQLServer
    27. Dim oDatabase As New SQLDMO.Database
    28. Dim oTable As New SQLDMO.Table
    29.    
    30.     If Node.Parent Is Nothing Then
    31.         Exit Sub
    32.     End If
    33.    
    34.     If Node.Parent = "SQL Server Group" Then
    35.         oSQLServer.Connect Node.Text, "poo", "plop"
    36.     Else
    37.         Exit Sub
    38.     End If
    39.    
    40.     For Each oDatabase In oSQLServer.Databases
    41.         With tvwMain
    42.             .Nodes.Add Node.Key, tvwChild, Node.Key & "\" & oDatabase.Name, oDatabase.Name
    43.             For Each oTable In oDatabase.Tables
    44.                 .Nodes.Add Node.Key & "\" & oDatabase.Name, tvwChild, Node.Key & "\" & oDatabase.Name & "\" & oTable.Name, oTable.Name
    45.             Next
    46.         End With
    47.     Next
    48.    
    49. End Sub
    Matt G
    VS6 Ent SP5 @ Work
    VS6 Ent SP5 & VB.Net @ Home
    [email protected]



  2. #2

    Thread Starter
    Hyperactive Member gravyboy's Avatar
    Join Date
    Jan 2000
    Location
    Where I was before . . . if you don't know then you're new!
    Posts
    334
    OK so the only way to do it is to query a server.....the Y t F is there a Status property in the SQLServer object? The object can only query a db if there is a connection . . . the query responds running,stopped, starting, paused etc....I ALREADY KNOW THIS IF THE CONNECT METHOD HAS FAILED!!!! *fuming*
    Matt G
    VS6 Ent SP5 @ Work
    VS6 Ent SP5 & VB.Net @ Home
    [email protected]



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width