代码如下:
< %
'功能:显示数据库中表名、字段名、字段内容
'原创:wangsdong
'原创文章,转载请保留此信息,谢谢
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 "表名:"&rs(2)&"<br />"
set rs1=server.createobject("adodb.recordset")
sql="select * from "&rs(2)
set rs1=conn.execute(sql)
response.write "字段名:"
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
% >
只要改变一下数据库名,然后运行一下这个程序,就可以看到结果了。
申明:本教程内容由威凡网编辑整理并提供IT程序员分享学习,如文中有侵权行为,请与站长联系(QQ:254677821)!