• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

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

asp 搞代码 4年前 (2022-01-03) 22次浏览 已收录 0个评论

此方法可获得ACCESS数据的表名及其结构,数据类型等… 程序过滤了几个ACCESS数据库的几个隐藏表(可能是导致ACCESS数据库删除数据还会变大的原因)

获取ACCESS数据库表名_www.gaodaima.com

数据库路径:


<%
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
%>


<%
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”))
En

来源gaodai.ma#com搞#代!码网

d If
End If
shm.MoveNext
Loop
response.write “共有 “&j&” 个数据表!”
else
response.write “

请输入数据库相对路径查看具体内容!


end if
%>

<%
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 “

“&vbcrlf
response.write “表 “&TableName&” 中含有”&Cont&”个字段,具体如下:
“&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 ” “&i&”“&rs.fields(i).name&”–“&filtype&”;
“&vbcrlf
Next
response.write “

“&vbcrlf
rs.Close
set rs=nothing
End Function
%>

以上就是ASP获取ACCESS数据库表名及结构的代码的详细内容,更多请关注gaodaima搞代码网其它相关文章!


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:ASP获取ACCESS数据库表名及结构的代码
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址