Results 1 to 2 of 2

Thread: How to get All SQL Server Names ?

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2002
    Posts
    2

    Cool How to get All SQL Server Names ?

    I am developing a client server system in VB and SQL back-end.

    I need to get all the SQL server names that are running in my domian.

    Then it allows me to give a drop down list of available servers to users to choose at the initial system start up.

    I know to get the current machine name and username etc by calling the windows APIs.

    Can SQL server names in the network be also retrieved with APIs ?

    Welecom your comments !
    Help Me ...

    Amal

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    VB Code:
    1. 'Add this code As a reference To the Microsoft SQLDMO Object Library (SQLDMO.DLL).
    2. 'NOTE:   To use SQLDMO objects you have to have Enterprise Manager
    3. 'installed. SQLDMO is the engine that drives Enterprise Manager.
    4.  
    5. Dim SQLApp As SQLDMO.Application
    6. Dim Names As SQLDMO.NameList
    7.    
    8. Set SQLApp = New SQLDMO.Application
    9. ' get available servers
    10. Set Names = SQLApp.ListAvailableSQLServers
    11.    
    12. Dim indx As Integer
    13.  
    14. ' add server names to Listbox control  
    15. For indx = 1 To Names.Count
    16.     List1.Additem Names.Item(indx)
    17. Next
    18.    
    19. Set Names = Nothing
    20. Set SQLApp = Nothing

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