Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
cn.CursorLocation = adUseClient
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\aa\Finished_kjkw\sc\Data.mdb;Persist Security Info=False"
cn.Open
Set rs = cn.OpenSchema(adSchemaTables)
Do While Not rs.EOF
If LCase(rs!table_type) = "table" Then MsgBox rs!table_name
rs.MoveNext
Loop
dim cn as new adodb.connection
dim rs as new adodb.recordset
cn.connectionstring="provider=microsoft.jet.4.0;datasource=ip\path\tablename"
cn.open
set rs=cn.openschema(adschematables)
do while not rs.eof then
if rs!table_type="table" then
'工程--->引用--->Microsoft DAO 3.6 Object Liarbry
Dim DaoDb As DAO.Database
Dim DaoTb As DAO.TableDef
Set DaoDb = OpenDatabase(gstrAppPath & "SysUpdate.mdb")
For Each DaoTb In DaoDb.TableDefs
msgbox DaoTb.name
Next
'引用adox
Sub disptables(mydbpath As String) '显示指定数据库中所有表名
Dim msg As String
Dim mycat As New ADOX.Catalog
msg = ""
Set mycat.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & mydbpath & ";"
For i = 0 To mycat.Tables.Count - 1
If Left(mycat.Tables.Item(i).Name, 4) <> "MSys" Then '去掉系统表
msg = msg & mycat.Tables.Item(i).Name & vbCrLf
End If
Next
MsgBox msg
End Sub
'----------------------------------------------------------------------------
'
'Author:lihonggen0
'Date:2003-6-19
'功能:获取access库中表的个数及表的名称
'用ado怎样实现
'工程--->引用--->Microsoft ActiveX Data Object 2.x(版本号)
'----------------------------------------------------------------------------
Private Sub Form_Load()
Dim adoCN As New ADODB.Connection '定义数据库的连接
Dim strCnn As New ADODB.Recordset
Dim I As Integer
str1 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\Northwind.MDB;Persist Security Info=False"
adoCN.Open str1
Set rstSchema = adoCN.OpenSchema(adSchemaTables)
Do Until rstSchema.EOF
If rstSchema!TABLE_TYPE = "TABLE" Then
out = out & "Table name: " & _
rstSchema!TABLE_NAME & vbCr & _
"Table type: " & rstSchema!TABLE_TYPE & vbCr
I = I + 1
End If
rstSchema.MoveNext
Loop
MsgBox I
rstSchema.Close