¤ how do I get the list of database ?
¤ like Northwind, etc ....
¤
¤ with ADO.NET ?
¤
¤
¤ same question for MySQL too
The below code will work with SQL Server. Keep in mind that the OLEDB database provider for the
database type will need to support this feature. Otherwise it is likely you will need to call a
stored procedure or query a database table which consists of the names of all of the databases for
the server. You also need to keep in mind that there may be security issues with respect to
accessing this information which is dependent once again upon the type of database you are working
with.
Dim DatabaseConnection As New System.Data.OleDb.OleDbConnection
Dim SchemaTable As DataTable
DatabaseConnection.ConnectionString = "Provider=sqloledb;" & _
"Data Source=(local);" & _
"Initial Catalog=Northwind;" & _
"Integrated Security=SSPI"
DatabaseConnection.Open()
'Retrieve schema information about the database catalogs.
SchemaTable =
DatabaseConnection.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Catalogs, Nothing)
Dim RowCount As Int32
For RowCount = 0 To SchemaTable.Rows.Count - 1
Console.WriteLine(SchemaTable.Rows(RowCount)!CATALOG_NAME.ToString)
Console.WriteLine(SchemaTable.Rows(RowCount)!DESCRIPTION.ToString)
Next RowCount
DataGrid1.DataSource = SchemaTable
DatabaseConnection.Close()
Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)