ASP obtains the table name and field name code in the database.

Source: Internet
Author: User

CopyCode The Code is as follows: <%
'Function: displays the table name, field name, and field content in the database.
'Original: wangsdong
'Originality Article Reprinted. Please keep this information. Thank you.

Set rs = server. Createobject ("ADODB. recordset ")
DB = "db1.mdb"
Set conn = server. Createobject ("ADODB. Connection ")
Connstr = "provider = Microsoft. Jet. oledb.4.0; Data Source =" & server. mappath (db)
Conn. Open connstr

Set rs = conn. openschema (20)
Do until Rs. EOF

If RS (3) = "table" then
Response. Write "table name:" & RS (2) & "<br/>"
Set RS1 = server. Createobject ("ADODB. recordset ")
SQL = "select * from" & RS (2)
Set rs1=conn.exe cute (SQL)
Response. Write "field name :"
For I = 0 to rs1.fields. Count-1
Response. Write rs1.fields (I). Name &""
Next
Response. Write "<br/>"

Do while not rs1.eof
Response. Write ""
For I = 0 to rs1.fields. Count-1
T = rs1.fields (I). Name
Response. Write RS1 (t )&""
Next
Response. Write ""
Rs1.movenext
Loop
Response. Write ""
End if

Rs. movenext
Loop

Set rs = nothing
Set conn = nothing
%>

Just change the Database Name and run thisProgramYou can see the result.

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.