Paul Clement
6/14/2004 8:37:00 PM
On Thu, 10 Jun 2004 21:12:33 -1000, "Robin HOIZEY \(Hotmail\)" <r_hoizey@hotmail.com> wrote:
¤ Hi everybody,
¤
¤ I'm trying to use an odbc connection to get the list of the available tabls
¤ in my database. But I cant't find the right way to do this.
You don't indicate what type of database you are working with but the ODBC Provider for .NET doesn't
support the retrieval of schema information. Use the OLEDB Provider for .NET instead.
Dim DatabaseConnection As New System.Data.OleDb.OleDbConnection
Dim SchemaTable As DataTable
DatabaseConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=E:\My Documents\db1.mdb"
DatabaseConnection.Open()
SchemaTable =
DatabaseConnection.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Tables, _
New Object() {Nothing, Nothing, Nothing, Nothing})
Dim RowCount As Int32
For RowCount = 0 To SchemaTable.Rows.Count - 1
Console.WriteLine(SchemaTable.Rows(RowCount)!TABLE_NAME.ToString)
Next RowCount
DataGrid1.DataSource = SchemaTable
DatabaseConnection.Close()
Paul ~~~ pclement@ameritech.net
Microsoft MVP (Visual Basic)