In VB6, I use Tabledef to get the list of tables in an Access database and display it in a combo box. How do you...
implement this in VB.Net? Here is how you can retrieve schema information from a database using ADO.NET. To use this code, create a data connection and call it ODC. Paste this code into a button on a form and add a label named label1 (You should use better names in real life ). This code will iterate through all database objects and print their names and values to the label control.
Dim DT As DataTable Dim SchemaGUID As OleDb.OleDbSchemaGuid Dim MyRow As DataRow Dim MyCol As DataColumn ODC.Open() DT = ODC.GetOleDbSchemaTable(SchemaGUID.Tables, Nothing) Label1.Text = "" For Each MyCol In DT.Columns If Not DT.Rows(0).IsNull(MyCol.ColumnName) Then Label1.Text += MyCol.ColumnName & " : " End If Next Label1.Text += vbCrLf For Each MyRow In DT.Rows For Each MyCol In DT.Columns If Not MyRow.IsNull(MyCol.ColumnName) Then Label1.Text += MyRow(MyCol.ColumnName) & " : " End If Next Label1.Text += vbCrLf Next
That should give you what you need to know. Just fill a combo box with the TABLE_NAME from each row in the DataTable.
The GetOleDbSchemaTable method of the OleDbConnection object provides schema data in ADO.NET. You provide this method with a GUID retrieved by calling the appropriate method of the OleDb.OleDbSchemaGuid object. Using these objects, you can retrieve a wealth of information about a database schema.
Dig Deeper on WCF (Windows Communication Foundation)
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.