摘要:如何列舉Access資料庫中的結構資訊
參考資料
OleDbConnection.GetOleDbSchemaTable 方法
- Dim CN As OleDb.OleDbConnection
- Dim DA As OleDb.OleDbDataAdapter
- Dim DT As DataTable
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- CN = New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\XXXXX.mdb;Persist Security Info=True")
- CN.Open()
- DT = CN.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, _
- New Object() {Nothing, Nothing, Nothing, "TABLE"})
- DisplayData(DT)
- End Sub
- Private Sub DisplayData(ByVal table As DataTable)
- For Each row As DataRow In table.Rows
- For Each col As DataColumn In table.Columns
- Debug.Print("{0} = {1}", col.ColumnName, row(col))
- Next
- Debug.Print("============================")
- Next
- End Sub