Enumerating SQL Server and SQL Express

Posted on 2011-10-13
Last Modified: 2012-06-21
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


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").ToString & "\" & oRow("InstanceName").ToString)
                    End If
                Next oRow
            End If
End If
Question by:Deadcats
    LVL 6

    Accepted Solution

    By default the SQL Express "SQL Server Browser" windows service is disabled. If you enable it, your code will be able to find it as well.

    Author Comment

    Thanks that took care of it.

    Author Closing Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
    Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now