如何取得一个access数据库下的所有的表的名称
展开全部
写了个函数
Public Function treeview()
Try
Dim connstr As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\WAB.mdb;User Id=admin;Password=; "
Dim objCn As New ADODB.Connection
objCn.Open(connstr)
Dim rstSchema As ADODB.Recordset
Dim adSchemaTables As ADODB.SchemaEnum
rstSchema = objCn.OpenSchema(ADODB.SchemaEnum.adSchemaTables)
Do Until rstSchema.EOF
If rstSchema("TABLE_TYPE").Value.ToLower = "TABLE".ToLower Then
Dim FileNode As TreeNode
ListView.Items.Add(rstSchema("TABLE_NAME").Value)
End If
rstSchema.MoveNext()
Loop
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Function
Public Function treeview()
Try
Dim connstr As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\WAB.mdb;User Id=admin;Password=; "
Dim objCn As New ADODB.Connection
objCn.Open(connstr)
Dim rstSchema As ADODB.Recordset
Dim adSchemaTables As ADODB.SchemaEnum
rstSchema = objCn.OpenSchema(ADODB.SchemaEnum.adSchemaTables)
Do Until rstSchema.EOF
If rstSchema("TABLE_TYPE").Value.ToLower = "TABLE".ToLower Then
Dim FileNode As TreeNode
ListView.Items.Add(rstSchema("TABLE_NAME").Value)
End If
rstSchema.MoveNext()
Loop
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Function
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询