VB.Net 如何获取Access数据库中的表名称
如何获取Access数据库中所有表的名称,最好有代码
Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click For i As Int16 = 0 To GetAllTableName.Count - 1 MsgBox(GetAllTableName.Item(i).ToString) Next End Sub Function GetAllTableName() As System.Collections.ArrayList Dim t As New System.Collections.ArrayList() Dim Rs As New ADODB.Recordset() Dim connStr As String = "provider=Microsoft.Jet.OLEDB.4.0; Data Source=d:\db2.mdb" Dim conn As New ADODB.Connection conn.Open(connStr) Rs = conn.OpenSchema(ADODB.SchemaEnum.adSchemaTables) Do While Not rs.EOF If rs("TABLE_TYPE").Value = "TABLE" Then t.Add(rs("TABLE_NAME").Value) End If rs.MoveNext() If rs.EOF Then Exit Do Loop Rs.Close() Rs = Nothing Return t End Function End Class