ListAvailableSQLServers

  • I use this method to return instances of sql servers to populate my login forms. All has worked well for years but today user asks "why does login form show only servers in FIRST sql server group?"

    I have not verified this behavior. I will do so shortly but I wonder if this is the default behavior?

    I don't see any DMO code to iterate through server groups then constituent servers. Does such an animal exist?

    TIA

    Brian Lockwood

    ApexSQL - value added SQL tools

    http://www.apexsql.com

    Brian Lockwood
    President
    ApexSQL - SQL Developer Essentials

    http://www.apexsql.com/blog

    Stand up for an Independent SQL Community - be Informed

  • This was removed by the editor as SPAM

  • Brian,

    In my experience ListAvailableSQLServers has only returned listening servers and those servers explicitly defined in Client Network Utility.

    To list enumerate all my EM registered groups, subgroups and servers I use VBS code such as:

     
    
    Dim oApplication, iLevel
    Set oApplication = CreateObject("SQLDMO.Application")

    Dim oServerGroup, oRegisteredServer
    iLevel = 1

    EnumerateSubGroups oApplication, 0

    Sub EnumerateSubGroups (oServerGroup, iLevel)

    Dim oServerSubGroup

    For Each oServerSubGroup In oServerGroup.ServerGroups
    wscript.echo space(iLevel*3) & " Server Group " & oServerSubGroup.Name & " (" & oServerSubGroup.ServerGroups.Count & " sub-groups)"

    If oServerSubGroup.ServerGroups.Count > 0 Then
    EnumerateSubGroups oServerSubGroup, iLevel+1
    End If

    For Each oRegisteredServer In oServerSubGroup.RegisteredServers
    wscript.echo space(iLevel*3) & " Server = " & oRegisteredServer.Name & vbCRLF _
    & space(iLevel*3) & " Trusted = " & oRegisteredServer.UseTrustedConnection & vbCRLF _
    & space(iLevel*3) & " Sysadmin = " & oRegisteredServer.SaLogin & vbCRLF _
    & space(iLevel*3) & " Login = " & oRegisteredServer.Login & vbCRLF _
    & space(iLevel*3) & " Password = " & oRegisteredServer.Password & vbCRLF _
    & space(iLevel*3) & " Version = " & oRegisteredServer.VersionMajor & "." & oRegisteredServer.VersionMinor
    Next

    Next

    End Sub

    Cheers,

    - Mark

    Edited by - mccork on 12/15/2003 04:50:26 AM


    Cheers,
    - Mark

  • thx much for reply.

    we verified that it did return all servers regardless of sql server group and also found some new APIs to do this without SQLDMO

    here are some notes from my developer:

    "This is a function for getting sql-servers names array without SQLDMO. The function "SQLBrowseConnect" of

    ODBC-API has been used instead of "NetServerEnum" of NET-API

    because "NetServerEnum" doesn't work on win95/98/Me but SQLBrowseConnect works anywhere where MDAC or SQL-client

    is installed. Likely, that ListAvailableSQLServers works over NetServerEnum is a common mistake or it is rightly for previous versions of DMO (6.5 and lower). As the current DMO loads "odbc32.dll", one uses ODBC-API too."

    Brian Lockwood

    ApexSQL - value added SQL tools

    http://www.apexsql.com

    Brian Lockwood
    President
    ApexSQL - SQL Developer Essentials

    http://www.apexsql.com/blog

    Stand up for an Independent SQL Community - be Informed

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply