SmoApplication.EnumAvailableSqlServers returns server names but not instance names (but only on one

Posted by Matma on Stack Overflow See other posts from Stack Overflow or by Matma
Published on 2010-05-21T08:36:19Z Indexed on 2010/05/21 8:40 UTC
Read the original article Hit count: 510

Hi, There are a number of questions about this and a number of possible causes and thus far ive tried them all with no success.

situation: i have an app that needs a db to work, onstartup it does a SmoApplication.EnumAvailableSqlServers(false) to get all the instances on the network, shows the user a dropdown, they pick one and i go connect to my db on that server. all good

problem: this works on my machine, the guys next to me and others. HOWEVER it doesnt work on one of the tech guys machines (and potentially others). we are all on the same network domain, physically connected (no wireless), all logged on with network user names, all running the same sql express 2005 sp3, though im using win7 the other guys are running xppro. MSSMS on all machines can see all the instances when you select "Browse for more".

yet on this one tech guys machine it lists his local instance (since its hardcoded to) and all the network servers, but has no instances names?

i.e.
.sqlexpress
server1
server2
server3
server4

but on my machine and others we get:
.sqlexpress
server1/sqlexpress
server2/sqlexpress
server3/sqlexpress
server4/sqlexpress

the code im using:

' .... some code 

' this populates my datatable 
dtServers = SmoApplication.EnumAvailableSqlServers(False) 

'.... some code 

'.... then later i ShowServers(...)  



Private dtServers As DataTable = Nothing
Private Sub ShowServers(ByVal SQLInstance As String)
    ' Create a DataTable where we enumerate the available servers
    cmbServer.Items.Clear()
    cmbDatabase.Items.Clear()

    ' If there are any (network listed) servers at all
    If (dtServers.Rows.Count > 0) Then
        ' Loop through each server in the DataTable
        For Each drServer As DataRow In dtServers.Rows
            ' Add the name to the combobox
            cmbServer.Items.Add(drServer("Server") & "\" & drServer("Instance"))
        Next
    End If

    'To make life simpler (add the local instance of sql express):
    cmbServer.Items.Add(SQLInstance)

    ' select first item
    If cmbServer.Items.Count > 0 Then
        cmbServer.SelectedIndex = 0
    End If
End Sub

now i know this uses udp and its not 100%, but how come his machine is 100% consistent in not showing remote instances, and mine is 100 consistent showing them. even a udl file on his desktop cant see them, regarldess of provider i choose to use? some of the suggestions are to uninstall and re-install, but that doesnt seem like a solution as i (and most others) can see the instances, but one guy cant. this suggests its not the remote sql server but rather the local machine.

Notes: ive tried firewall 1433, 1434 i can connect using a udl with full SERVERNAME\INSTANCENAME the browser service is running locally and on the remote machine ive tried stopping and restarting both the browser service on the local and remote machine.

Ideas?

© Stack Overflow or respective owner

Related posts about sql

Related posts about sql-server-instances