不错呦!smile@林凯西,确保“准备文件”中的几个文件都有安装,S...您好,看了您这篇帖子觉得很有帮助。但是有个问题想请...我的修改过了怎么还被恶意注册呢 @jjjjiiii 用PJ快9年了,主要是A...PJ3啊,貌似很少有人用PJ了,现在不是WP就是z...@332347365,我当时接入时错误码没有-10...楼主,ChkValue值应为-103是什么意思呢?...大哥 你最近能看到我发的信息,请跟我联系,我有个制...
读取ACCESS库中所有表及其字段名称
编辑:dnawo 日期:2006-12-05
公司有一套ASP+ACCESS的后台程序,我要尽快了解,在了解其数据库结构的时候对着ACCESS非常的不直观,便想将所有表名称及其字段名称打印出来,输出这些内容便成问题,有没有办法用ASP将这些内容输出到一个页面呢?搜索了相关资料后总算是实现了,下边是程序:
<%
Dim conn,rs,rs2,sqlstr,t_count,table_name,i
On error resume next
Set conn = Server.CreateObject("ADODB.Connection")
Conn.Connectionstring="provider=Microsoft.Jet.OLEDB.4.0;Data source=" & Server.MapPath("data1.mdb")
Conn.open
If err then
Response.write "请检查数据库路径!"
err.clear
Response.End
End if
T_count = 0
Set rs = Conn.openschema(20)
Do while not rs.eof
If rs("table_type")="TABLE" then
T_count = T_count + 1
table_name = rs("table_name")
Response.write "<b>表" & table_name & ":</b><br>"
Sqlstr = "select * from " & table_name
Set rs2 = Server.CreateObject("ADODB.RecordSet")
Rs2.open sqlstr,conn,0,1
For i=0 to rs2.fields.count-1
If i = rs2.fields.count-1 then
Response.write rs2.fields.item(i).name
Else
Response.write rs2.fields.item(i).name & ","
End if
Next
Response.write "<p>"
Rs2.close
Set rs2 = nothing
End if
Rs.movenext
Loop
Response.write "<u><b>总计</b><font color=red>" & t_count & "</font><b>个表</b></u>"
Rs.close
Set rs = nothing
Conn.close
Set conn=nothing
%>
其中主要是运用了Connection对象的openschema方法,这边要注意的是rs("table_type")="TABLE"一句中TABLE一定要大写。此方法在ASP教材中很少看到,搜索了大量资料后我还不是非常了解,下边是我搜索到的两篇相关文章,有兴趣的朋友可以看看:
http://dev.csdn.net/article/68/68466.shtm
http://fishcat.blog.com.cn/archives/2006/386828.shtml
<%
Dim conn,rs,rs2,sqlstr,t_count,table_name,i
On error resume next
Set conn = Server.CreateObject("ADODB.Connection")
Conn.Connectionstring="provider=Microsoft.Jet.OLEDB.4.0;Data source=" & Server.MapPath("data1.mdb")
Conn.open
If err then
Response.write "请检查数据库路径!"
err.clear
Response.End
End if
T_count = 0
Set rs = Conn.openschema(20)
Do while not rs.eof
If rs("table_type")="TABLE" then
T_count = T_count + 1
table_name = rs("table_name")
Response.write "<b>表" & table_name & ":</b><br>"
Sqlstr = "select * from " & table_name
Set rs2 = Server.CreateObject("ADODB.RecordSet")
Rs2.open sqlstr,conn,0,1
For i=0 to rs2.fields.count-1
If i = rs2.fields.count-1 then
Response.write rs2.fields.item(i).name
Else
Response.write rs2.fields.item(i).name & ","
End if
Next
Response.write "<p>"
Rs2.close
Set rs2 = nothing
End if
Rs.movenext
Loop
Response.write "<u><b>总计</b><font color=red>" & t_count & "</font><b>个表</b></u>"
Rs.close
Set rs = nothing
Conn.close
Set conn=nothing
%>
其中主要是运用了Connection对象的openschema方法,这边要注意的是rs("table_type")="TABLE"一句中TABLE一定要大写。此方法在ASP教材中很少看到,搜索了大量资料后我还不是非常了解,下边是我搜索到的两篇相关文章,有兴趣的朋友可以看看:
http://dev.csdn.net/article/68/68466.shtm
http://fishcat.blog.com.cn/archives/2006/386828.shtml
评论: 1 | 引用: 0 | 查看次数: 3984
发表评论
请登录后再发表评论!