摘要:透過ADO取得Access資料庫的所有資料表名稱
感謝小舖中的老頑童大大提供的方法
Dim DbFile, DBPath, Conn, Rs
DbFile="Db.mdb"
Set conn = Server.CreateObject("ADODB.Connection")
DBPath = Server.MapPath(DbFile)
Conn.open "Driver={Microsoft Access Driver (*.mdb)}; Dbq=" & DBPath
Const adSchemaTables = 20
Set Rs = Conn.OpenSchema(adSchemaTables,array(empty,empty,empty,"Table"))
If Not(rs.BOF And rs.EOF) Then
rs.MoveFirst
For y = 1 to rs.RecordCount
Response.Write Rs("Table_Name") & ""
Rs.MoveNext
Next
Rs.Close
Set Rs = Nothing
Conn.Close
Set Conn = Nothing
DbFile="Db.mdb"
Set conn = Server.CreateObject("ADODB.Connection")
DBPath = Server.MapPath(DbFile)
Conn.open "Driver={Microsoft Access Driver (*.mdb)}; Dbq=" & DBPath
Const adSchemaTables = 20
Set Rs = Conn.OpenSchema(adSchemaTables,array(empty,empty,empty,"Table"))
If Not(rs.BOF And rs.EOF) Then
rs.MoveFirst
For y = 1 to rs.RecordCount
Response.Write Rs("Table_Name") & ""
Rs.MoveNext
Next
Rs.Close
Set Rs = Nothing
Conn.Close
Set Conn = Nothing
以下是簽名:
- 歡迎轉貼本站的文章,不過請在貼文主旨上加上【轉貼】,並在文章中附上本篇的超連結與站名【topcat姍舞之間的極度凝聚】,感恩大家的配合。
- 小喵大部分的文章會以小喵熟悉的語言VB.NET撰寫,如果您需要C#的Code,也許您可以試著用線上的工具進行轉換,這裡提供幾個參考
Microsoft MVP Visual Studio and Development Technologies (2005~2019/6) | topcat Blog:http://www.dotblogs.com.tw/topcat |