Asp obtains access system tables, queries, and other operation code

Source: Internet
Author: User

Method 1: Open adSchemaTables directly using the OpenSchema () method of ado and create a schema record set.

Code:
<%
Const adSchemaTables = 20
AdSchemaColumns = 4
Dim Conn, db
Dim ConnStr
Db = "temp. mdb" 'Access database file name, use the absolute path relative to the website root directory
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
%>

Method 2: The Access System Table MsysObjects contains a list of database objects. Although it is not recorded in the document, you can query it to obtain what you want. However, the system table cannot be operated by default. You must manually set the permission to receive the table.
See the following Animation: how to get the http://blog.iyi.cn/user/david/archives/IMAGES/msobject.swf for msysobject operation Permissions

However, I cannot find these system tables in access2003. I don't know if m $ enhances access security.

Use the following SQL statement to obtain

Code:
Query:
SELECT MSysObjects. Name FROM MsysObjects WHERE (Left ([Name], 1) <> "~ ") AND (MSysObjects. Type) = 5 order by MSysObjects. Name;

Form:
SELECT MSysObjects. Name FROM MsysObjects WHERE (Left ([Name], 1) <> "~ ") AND (MSysObjects. Type) =-32768 order by MSysObjects. Name;

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

Report:
SELECT MSysObjects. Name FROM MsysObjects WHERE (Left ([Name], 1) <> "~ ") AND (MSysObjects. Type) =-32764 order by MSysObjects. Name;

Module:
SELECT MSysObjects. Name FROM MsysObjects WHERE (Left ([Name], 1) <> "~ ") AND (MSysObjects. Type) =-32761 order by MSysObjects. Name;

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.