Results 1 to 6 of 6

Thread: [RESOLVED] [2005] Getting a list of MSSQL servers

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2006
    Posts
    5

    Resolved [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

  2. #2
    Frenzied Member Asgorath's Avatar
    Join Date
    Sep 2004
    Location
    Saturn
    Posts
    2,036

    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."

  3. #3
    Addicted Member
    Join Date
    Jan 2007
    Posts
    220

    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,

  4. #4
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: [2005] Getting a list of MSSQL servers

    Add a reference to Microsoft SQLDMO Object Library. Then use this statement at the top
    vb Code:
    1. Imports SQLDMO
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  5. #5
    Frenzied Member Asgorath's Avatar
    Join Date
    Sep 2004
    Location
    Saturn
    Posts
    2,036

    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."

  6. #6

    Thread Starter
    New Member
    Join Date
    Feb 2006
    Posts
    5

    Resolved 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
  •  



Click Here to Expand Forum to Full Width