• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

ASP获取ACCESS数据库表名及结构的代码

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

<html>
<head>
<title>获取ACCESS数据库表名_www.ogeek.net</title>
</head>
<body style="text-align:left;margin-left:50px;font-family:'arial';font-size:12px">
<form style="padding:5px;margin:5px;margin-left:0px" name="get" action="" method="post">
数据库路径:<input type="text" name="path" value="" size="50" />
<input type="hidden" name="ari" value="1" />
<input type="submit" value="查看" />
</form>
<hr>
<%
if request.form("ari")="1" and request.form("path")<>"" then
dim conn,connstr,i,sql,rs
on error resume next
Connstr="DRIVER=Microsoft Access Driver (*.mdb);DBQ="+server.mappath(request.form("path"))
Set Conn=Server.CreateObject("ADODB.Connection")
conn.Open connstr
If Err Then
err.Clear
Set Conn = Nothing
Response.Write "数据库连接出错,请检查连接字串。"
Response.End
End If
%>
<font color=red><%=conn.connectionstring%></font><hr>
<%
j=0
dim tablecount
tablecount=0
Set shm = conn.OpenSchema(20)
shm.MoveFirst
Do While Not shm.EOF
If shm("TABLE_TYPE") = "TABLE" Then
If Left(shm("table_name"), 1) <> "~" Then '这里过滤掉隐藏表
j=j+1
call GetFileds(shm("table_name"))
End If
End If
shm.MoveNext
Loop
response.write "共有 "&j&" 个数据表!"
else
response.write "<h3>请输入数据库相对路径查看具体内容!</h3>"
end if
%>
</body>
</html>
<%
Function GetFileds(TableName)
Set rs = server.createobject("adodb.recordset")
Dim SQL
SQL = "select * from " & TableName
rs.Open SQL, conn, 1, 1
Dim Cont
Cont = rs.Fields.Count
response.write "<div style=""margin-bottom:10px;padding:5px;border:1px #dddddd solid;background:#eeeeee"">"&vbcrlf
response.write "表 <font color=red><b>"&TableName&"</b></font> 中含有"&Cont&"个字段,具体如下:<br>"&vbcrlf
For i = 0 To Cont - 1
dim filtype
select case rs.fields(i).type
case 3
filtype="自动编号(数字)"
case 202
filtype="字符"
case 203
filtype="备注"
case 125
filtype="日期"
case 11
filtype="真/假(是/否)"
end select
response.write " <font color=red>"&i&"</font>--<font color=green><b>"&rs.fields(i).name&"</b></font>--"&filtype&";<br />"&vbcrlf
Next
response.write "</div>"&vbcrlf
rs.Close
set rs=nothing
End Function
%>

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
asp之让Session永不过期发布时间:2022-02-05
下一篇:
推荐一篇不错的新手asp编程的基本法则第1/2页发布时间:2022-02-05
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap