Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find sql server on a network

Status
Not open for further replies.

steve1rm

Programmer
Aug 26, 2006
255
GB
Hello,

I am creating a application that can connect any sql server on the network.

The customer would like a dialog box to be able to find a instance of a server, and then enter the password and username to get a list of all the database they want to connect to.

Does anyone have any examples projects in vb.net that does something like this.

I will be most grateful for any code.

Thanks in advance,

Steve
 
You can use SQL DMO


Code:
''' <summary>
    ''' Gets a list of servers
    ''' </summary>
    ''' <returns></returns>
    ''' <remarks></remarks>
    <Description("Gets a list of servers")> _
    Public Function GetServers() As String()

        Dim ServerNameList As Global.SQLDMO.NameList

        '** Configure Server
        _SQLServer = New Global.SQLDMO.SQLServer2
        _SQLServer.LoginTimeout = 10
        _SQLServer.ODBCPrefix = False

        '** Get the list of available servers.
        Dim R() As String
        ServerNameList = _SQLServer.Application.ListAvailableSQLServers
        ReDim R(ServerNameList.Count - 1)
        For intC As Int16 = 1 To ServerNameList.Count
            R(intC - 1) = (ServerNameList.Item(intC))
        Next

        Return R

    End Function

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top