vb.net, getting list of databases from sql server

vb.net, getting list of databases from sql server

Post by thomasvmatt.. » Fri, 08 Sep 2006 01:14:44



hi dudes,

i am choosing an sql server to connect to via a combobox, and then i
would like the databases within that server to populate ANOTHER
combobox.  anyone know how to go about this?  thanks!

~Tom

 
 
 

vb.net, getting list of databases from sql server

Post by Abhi Rohil » Fri, 08 Sep 2006 01:42:42


Go to

http://www.codeproject.com/vb/net/SQLVBCoder.asp

I hope this solves the purpose.


Quote:

> hi dudes,

> i am choosing an sql server to connect to via a combobox, and then i
> would like the databases within that server to populate ANOTHER
> combobox.  anyone know how to go about this?  thanks!

> ~Tom


 
 
 

vb.net, getting list of databases from sql server

Post by Jamie Frase » Fri, 08 Sep 2006 17:10:37


Try this;
 
 
 

vb.net, getting list of databases from sql server

Post by Jamie Frase » Fri, 08 Sep 2006 17:10:56


Oops, other reply got cropped;

 Private Sub LoadTablesInDb(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles _txtMachineName.Leave
      Dim sqlConn As New SqlClient.SqlConnection(Me.ConnectionString)
      Dim sqlCommand As New SqlClient.SqlCommand("sp_databases", sqlConn)

      Try
         sqlConn.Open()
         sqlCommand.CommandType = CommandType.StoredProcedure

         Dim schemaReader As SqlDataReader = sqlCommand.ExecuteReader()

         While schemaReader.Read()
            _cmbTables.Items.Add(schemaReader.Item(0))
         End While
      Catch ex As Exception
         Debug.WriteLine(ex.Message)
      Finally
         sqlConn.Close()
      End Try
   End Sub


Quote:

> hi dudes,

> i am choosing an sql server to connect to via a combobox, and then i
> would like the databases within that server to populate ANOTHER
> combobox.  anyone know how to go about this?  thanks!

> ~Tom

 
 
 

vb.net, getting list of databases from sql server

Post by Cerebru » Fri, 08 Sep 2006 17:48:31


Jamie Fraser wrote :

Quote:> (code snipped.)

That's what I call Sweet and simple !