要查詢或定義資料庫的內部結構(例如:欄位、主鍵、table name、view name等),就要用ADOX物件。
要使用ADOX之前,要先用ADO建立連結,之後才能使用ADOX物件。
Dim objConn as object, objCat as object, objTbl as object
set objConn=createobjcet("ADODB.connection")
set objCat=createobjcet("ADOX.catalog")
set objTbl=createobjcet("ADOX.table")
with objConn
.connectionstring="Provider="Microsoft.Jet.OLEDB.4.0; data source=mypath/myAccessFile.mdb"
.open
end with
with objCat
.activeconnection=objconn
for each objTbl in objCat.tables
debug.print objTbl.name
next
end with
沒有留言:
張貼留言