|
-
May 31st, 2007, 06:54 AM
#1
Thread Starter
New Member
[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
-
Jun 5th, 2007, 05:03 AM
#2
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.
"The dark side clouds everything. Impossible to see the future is."
-
Jun 5th, 2007, 05:16 AM
#3
Addicted Member
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,
-
Jun 5th, 2007, 05:34 AM
#4
Re: [2005] Getting a list of MSSQL servers
Add a reference to Microsoft SQLDMO Object Library. Then use this statement at the top
Use [code] source code here[/code] tags when you post source code.
My Articles
-
Jun 5th, 2007, 05:51 AM
#5
Re: [2005] Getting a list of MSSQL servers
like i said it won't list ms sql server 2005.
"The dark side clouds everything. Impossible to see the future is."
-
Jun 5th, 2007, 06:18 AM
#6
Thread Starter
New Member
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|