Advertisement

07.21.2008 at 11:46AM PDT, ID: 23582910
[x]
Attachment Details

How can I list all the databases on a SQL Server in a VB.Net Winforms Combobox?

Asked by mj_stanton in .NET, Microsoft Visual Basic.Net

Hi

I am using the code below to get a list of available SQL Servers & Instances in a VB.NET Winforms application running on version 3.5 of the .Net framework.

        Me.Cursor = Cursors.WaitCursor
        Me.Label_SQLserver.Text = "Searching..."
        Dim dtTest As New DataTable
        dtTest = Sql.SqlDataSourceEnumerator.Instance.GetDataSources

        Dim row As DataRow
        For Each row In dtTest.Rows
            ComboBox1.Items.Add(row("ServerName") & "\" & row("InstanceName")) ' Seeking Result: ServerName\InstanceName
        Next

        ComboBox1.DroppedDown = True
        Me.Label_SQLserver.Text = ""
        Me.Cursor = Cursors.Default

The above works great but what I want to do now is using the "ServerName\InstanceName" along with "username" and "password" credentials to fill a combobox with Databases available on that SQL server.

The end result I wish to achieve with the above is to use this winform to build a SQL Connection String.

Thanks for your help in advance.

Matthew

Start Free Trial
[+][-]07.21.2008 at 01:10PM PDT, ID: 22053887

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: .NET, Microsoft Visual Basic.Net
Sign Up Now!
Solution Provided By: FernandoSoto
Participating Experts: 1
Solution Grade: A
 
 
[+][-]07.22.2008 at 06:01AM PDT, ID: 22058833

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_EXPERT_20070906