Option Explicit
'请先添加引用dao3.6..
Private Sub Command1_Click()
Dim daoConnect As DAO.Database
Dim daoTable As DAO.TableDef
Dim daoTables As DAO.TableDefs
Set daoConnect = DAO.OpenDatabase("D:\vb60实例\mdb\score02.mdb")
Set daoTables = daoConnect.TableDefs
For Each daoTable In daoTables
If daoTable.Attributes And dbSystemObject Then
'此为系统表,不需要它.
Else
Print daoTable.Name
End If
Next
daoConnect.Close
End Sub
学了一招,ADO是不是也是一样的啊?
利用 ADO 获取数据库表名
dim db as adodb.connection
set db = new adodb.connection
db.open "provider=microsoft.jet.oledb.4.0; data source=" & app.path & "\db.mdb"
dim rs as adodb.recordset
set rs = db.openshema(adschematable)
while not rs.eof
debug.pring rs("tablename")
rs.movenext
wend
rs.close: set rs = nothing
db.close: set db = nothing