asp 擷取access系統資料表,查詢等作業碼

來源:互聯網
上載者:User

方法一:直接用ado的OpenSchema()方法開啟adSchemaTables,建立一個schema記錄集

Code:
<%
Const adSchemaTables = 20
adSchemaColumns = 4
dim Conn,db
dim ConnStr
db="temp.mdb" 'ACCESS資料庫的檔案名稱,請使用相對於網站根目錄的的絕對路徑
ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(db)
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open connstr

Dim rstSchema
Dim I

Set rstSchema = Conn.OpenSchema(adSchemaTables)

Do while not rstSchema.EOF
response.write("Table name: "& rstSchema("TABLE_NAME") & vbCr & _
"Table type: " & rstSchema("TABLE_TYPE") & vbCr)
response.write("<br/>")
I = I + 1
rstSchema.MoveNext
Loop
rstSchema.Close

conn.Close
%>

方法二:Access 系統資料表 MsysObjects 包含了資料庫物件列表。儘管未在文檔中記載,你仍可通過查詢它來擷取你想要的。但是預設情況下無法作業系統表,必須手動設定許可權收才能查詢系統資料表。
請參考以下動畫:如何擷取對msysobject的操作許可權 http://blog.iyi.cn/user/david/archives/IMAGES/msobject.swf

但是我在access2003中找不到這幾個系統資料表,不知道是不是m$增強了access的安全性。

使用下列 SQL 陳述式來擷取你想要的

Code:
查詢:
SELECT MSysObjects.Name FROM MsysObjects WHERE (Left([Name],1)<>"~") AND (MSysObjects.Type)=5 ORDER BY MSysObjects.Name;

表單:
SELECT MSysObjects.Name FROM MsysObjects WHERE (Left([Name],1)<>"~") AND (MSysObjects.Type)=-32768 ORDER BY MSysObjects.Name;

表:
SELECT MSysObjects.Name FROM MsysObjects WHERE (Left([Name],1)<>"~") AND (Left$([Name],4) <> "Msys") AND (MSysObjects.Type)=1 ORDER BY MSysObjects.Name;

報表:
SELECT MSysObjects.Name FROM MsysObjects WHERE (Left([Name],1)<>"~") AND (MSysObjects.Type)= -32764 ORDER BY MSysObjects.Name;

模組:
SELECT MSysObjects.Name FROM MsysObjects WHERE (Left([Name],1)<>"~") AND (MSysObjects.Type)= -32761 ORDER BY MSysObjects.Name;

宏:
SELECT MSysObjects.Name FROM MsysObjects WHERE (Left([Name],1)<>"~") AND (MSysObjects.Type)= -32766 ORDER BY MSysObjects.Name;

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.