Using GetOleDbSchemaTable to Get Columns from Access Table
Reading the access Db remarks & Field type . on Developer Newsgroups
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.Columns, _
New Object() {Nothing, Nothing, 'PutTheTableNameHere'})
Dim RowCount As Int32
For RowCount = 0 To SchemaTable.Rows.Count - 1
Console.WriteLine(SchemaTable.Rows(RowCount)!COLUMN_NAME.ToString)
Next RowCount
'Shows what information is available
DataGrid1.DataSource = SchemaTable
DatabaseConnection.Close()
Code leached to avoid losing it in the future (since it was posted to a forum/news group). All rights retained by the original author, etc, etc, etc...
Using GetOleDbSchemaTable is not the easiest thing in the world, so I wanted to capture this...
Past Post XRef:
MS Access System Information via OleDbCommand.GetOleDbSchemaTable
No comments:
Post a Comment