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
NOTE: Anonymous Commenting has been turned off for a while... The comment spammers are just killing me...
ALL comments are moderated. I will review every comment before it will appear on the blog.
Your comment WILL NOT APPEAR UNTIL I approve it. This may take some hours...
I reserve, and will use, the right to not approve ANY comment for ANY reason. I will not usually, but if it's off topic, spam (or even close to spam-like), inflammatory, mean, etc, etc, well... then...
Please see my comment policy for more information if you are interested.
Thanks,
Greg
PS. I am proactively moderating comments. Your comment WILL NOT APPEAR UNTIL I approve it. This may take some hours...