[RESOLVED] [2005] Getting a list of MSSQL servers
Hi.
I found some info on the C# forums but my problem is a bit different.
http://vbforums.com/showthread.php?t=459135
Im using the following code to get a list of servers on our network:
Code:
Dim sqlApp As New SQLDMO.Application
Dim sqlServers As SQLDMO.NameList = sqlApp.ListAvailableSQLServers
For Each srv As String In sqlServers
If srv <> Nothing Then
Me.ListBox1.Items.Add(srv)
End If
Next
I get no errors when running this code, but the results differ; no servers found, (local) and servers on other machines.
Does anyone have any idea why this happens?
The other computers in the network have both 2000/2005 MSSQL.
My local MSSQL is 2005 Dev.
Thanks,
Torbis
Re: [2005] Getting a list of MSSQL servers
Hi
It won't show ms sql server 2005.
Probably a limitation of the outdated SQL DMO.
Re: [2005] Getting a list of MSSQL servers
Hi,
I just wanted to know that do you need to import anything other than system.data and system.data.sqlclient for the above function.
Regards,
Re: [2005] Getting a list of MSSQL servers
Add a reference to Microsoft SQLDMO Object Library. Then use this statement at the top
Re: [2005] Getting a list of MSSQL servers
like i said it won't list ms sql server 2005.
Re: [SOLVED] [2005] Getting a list of MSSQL servers
Hi.
Thx for replies.
This will show the 2005 Sql Servers (at least on my network).
Code:
Imports Microsoft.SqlServer.Management.Smo
Dim dt As DataTable = SmoApplication.EnumAvailableSqlServers(False)
If dt.Rows.Count > 0 Then
For Each dr As DataRow In dt.Rows
Me.ListBox2.Items.Add(dr("Name"))
Next
End If
This namespace, class, or member is supported only in version 2.0 of the Microsoft .NET Framework.
http://msdn2.microsoft.com/en-us/lib...plication.aspx
Torbis