Listing database servers on local network

  • Thread starter Thread starter DKC
  • Start date Start date
D

DKC

Hi All,

Is there any way wherein I can get a list of database servers on my local
network.
Any help appreciated.
I am using VB.NET 2003

Thanks
DKC
 
Hi DKC

Some sample code, (I think it is only for SQL servers however I do not know
it because the sample is not from me)

However maybe you can use it.

Cor

\\\
Private Function LoadSQLServerList() As Integer
Dim serverIndex As Integer
Dim sqlServers As SQLDMO.NameList
Dim sqlServer As Object
' Get a list of servers
sqlServers = New SQLDMO.Application().ListAvailableSQLServers()
' Iterate through the server names, and add it to the combobox
For Each sqlServer In sqlServers
If Not sqlServer Is Nothing Then
cboServers.Items.Add(sqlServer)
End If
Next
' Send back the count of servers
LoadSQLServerList = cboServers.Items.Count
'table list in a ser
Dim sqlServer As SQLDMO.SQLServer
Dim sqlDB As Object
sqlServer = New SQLDMO.SQLServer()
Try
' Connect to your database with userID and password
sqlServer.Connect(cboServers.Text, txtUserID.Text,txtPassword.Text)
' Check for database names in the server
' This loop adds the database name to another combobox
For Each sqlDB In sqlServer.Databases
If Not sqlDB.Name Is Nothing Then
cboDatabases.Items.Add(sqlDB.name)
End If
Next
Catch Exp As Exception
MsgBox(Exp.ToString)
End Try
////
 
Back
Top