Try this:
Using con As New SqlConnection(strConnect)
con.Open()
Using cmd As New SqlCommand("sp_databases", con)
cmd.CommandType = CommandType.StoredProcedure
Dim read As SqlDataReader = cmd.ExecuteReader()
While read.Read()
Console.WriteLine(DirectCast(read("DATABASE_NAME"), String))
End While
End Using
End Using
All you have to do is sort out getting the info into the combobox.
If you use a DataView as the Combobox DateSource, you should be able to apply filters in the normal way (I haven't tried it with a Combobox, but it works fine with DataGridViews.)
"i have a problem, i dont know how to filter databases according to the tables inside them. Example i only want to show databases with the table "user" inside. How do i do that? thanks"
You will need to query each DB in turn.
Try connecting to the DB and using:
SELECT TABLE_NAME
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE = 'BASE TABLE'
Alternatively without specifying the DB in the connection:
USE yourDBName; SELECT name FROM sys.Tables