Link to home
Start Free TrialLog in
Avatar of Deadcats
DeadcatsFlag for United States of America

asked on

Enumerating SQL Server and SQL Express

Hello All

I have written an application in VB.Net 2010 that requires Sql Server. I have also created an install program that will install SQL Server Express 2008 if it does not find SQL Server. This all works in regards to installing SQL Express if it is needed and SQL Express shows up in my running process. The problem I am having is that I have a routine that will enumerate the servers that are available to this computer but it will not list the SQL Server Express that I just installed. This computer is not connected to a network so it does not know about the instances that are installed on my network. If I connect it to the network it finds the network SQL Servers but not the local one. Can anyone tell me what I'm doing wrong. I have tried this on both Vista and Windows 7 and I have formatted the machine so I know everything is clean. I have included the code that I am using to enumerate the servers below.

Thanks in Advance DC

DC

If lbServers.Items.Count = 0 Then
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor
                oTable = System.Data.Sql.SqlDataSourceEnumerator.Instance.GetDataSources

                For Each oRow As DataRow In oTable.Rows
                    If oRow("InstanceName").ToString = "" Then
                        lbServers.Items.Add(oRow("ServerName"))
                    Else
                        lbServers.Items.Add(oRow("ServerName").ToString & "\" & oRow("InstanceName").ToString)
                    End If
                Next oRow
            End If
End If
ASKER CERTIFIED SOLUTION
Avatar of regevha
regevha

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Deadcats

ASKER

Thanks that took care of it.
Thanks