如何列舉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

留言

這個網誌中的熱門文章

開啟cshtml檔案時,出現『並未將物件參考設定為物件執行個體』的錯誤訊息

無法設定中斷點 尚未載入符號檔

DataGridView欄位計算總合