ListAvailableSQLServers Not Showing Local Server

  • I'm using the following code to show all SQL servers:

    Dim i As Integer

    Dim oNames As SQLDMO.NameList

    Dim oSQLApp As SQLDMO.Application

    Me.cmbSQLServer.Items.Clear()

    oSQLApp =

    New SQLDMO.Application

    oNames = oSQLApp.ListAvailableSQLServers()

    For i = 1 To oNames.Count

      Me.cmbSQLServer.Items.Add(oNames.Item(i))

    Next i

    This works for all servers on the network except for the local server which it shows only as "(local)".  I can connect to all other servers except for "(local)".  The actual name of the local server is "B3\SQLEXPRESS".  When I try to connect to "B3\SQLEXPRESS" it works.
     
    I've looked all over the internet for a solution to return the local SQL server's name but I cannot find anything that works.  I've even tried to turn off my firewall as I've seen suggested but still it doesn't work.
     
    I'm using VB 2005 Express and SQL Server 2005 Express.
     
    Any help with this would be appreciated.
     
    Thanks,
    Dan
  • This was removed by the editor as SPAM

  • I had the same problem I also was using DMO.

    I decided to work with SMO and it worked.

    The following is the code I used instead.

    Imports Microsoft.SqlServer.Management.Smo

    Imports Microsoft.SqlServer.Management.Common

    Dim dts As DataTable = SmoApplication.EnumAvailableSqlServers(False)

    cmbSServers.DataSource = dts

    cmbSServers.ValueMember = "Name"

    SMO is the WAY TO GO !!!!

  • Hey -

    I have now seen this solution in two forums - and when I try and run this (mind you, I am very new to this), it looks like it cannot find any entry for "Imports Microsoft.SqlServer.Management.Common"...Am I missing something? is there something not installed correctly?

    TIA

    -- Cory

  • Okay - I found the answer to my question (Microsoft.SqlServer.ConnectionInfo)...

    now I get Name 'cmbSServers' is not declared, which is true, it is not...but...???

    I will need to sit down with some books and read up on this...I dont even know what to ask.

    -- Cory

  • I am an idiot. I figured it out.

    -- Cory

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply