我正在嘗試獲取 ms access 資料庫的所有表的名稱并存盤在一個陣列中。有沒有辦法做到這一點?或對此進行修改,我復制了這段代碼,所以我不知道它是干什么用的
con1.Open()
Dim Restrictions() As String = {Nothing, Nothing, "Table1", Nothing}
Dim CollectionName As String = "Columns"
Dim dt As DataTable = con1.GetSchema(CollectionName, Restrictions)
For Each TableRow As DataRow In dt.Rows
Console.WriteLine(TableRow.Item("COLUMN_NAME").ToString)
Next
con1.Close()
uj5u.com熱心網友回復:
要獲取資料庫中所有表的名稱,您應該使用包含 4 個 Nothing 值的限制和一個名為 TABLES 的集合。
con1.Open()
' No filter on the returned values
Dim Restrictions() As String = {Nothing, Nothing, Nothing, Nothing}
' Just interested in the TABLES collection
Dim CollectionName As String = "TABLES"
' Get the datatable with informations about the tables in the current db
Dim dt As DataTable = con1.GetSchema(CollectionName, Restrictions)
con.Close()
現在將所有內容傳遞回您可以使用的字串陣列中的呼叫代碼
Dim names = dt.Rows.Cast(Of DataRow).Select(Function(x) x("TABLE_NAME")).ToArray()
return names
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/415366.html
標籤:
上一篇:VB.NET到C#錯誤:“As”不是“Task(OfIFlurlResponse)”的成員
下一篇:在VB.NET中,有沒有辦法將未更改單元格的DataGridViewComboBox下拉串列更改為新的串列陣列,同時保留更改的單元格?
