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

来源:asp之家 时间:2011-04-15 10:50:00 


<html> 
<head> 
<title>获取ACCESS数据库表名 - www.cidianwang.com</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 
%>

标签:ASP,ACCESS表名
0
投稿

猜你喜欢

  • Python二进制数据结构Struct的具体使用

    2022-07-10 00:01:59
  • 解决golang读取http的body时遇到的坑

    2024-02-13 19:47:32
  • python 基于TCP协议的套接字编程详解

    2023-09-11 21:09:30
  • win7系统安装SQLServer2000的详细步骤(图文)

    2024-01-27 02:39:26
  • PHP Document 代码注释规范

    2023-11-14 11:50:54
  • Oracle Index 的三个问题

    2024-01-14 20:20:40
  • 如何列出SQL数据库中的存储过程?

    2010-01-12 19:58:00
  • js验证表单(form)中多选框(checkbox)值

    2008-03-18 13:39:00
  • python opencv实现证件照换底功能

    2021-06-22 07:17:58
  • Python使用百度api做人脸对比的方法

    2023-08-18 12:52:24
  • Python cookbook(数据结构与算法)对切片命名清除索引的方法

    2023-10-31 02:27:35
  • 关于Mysql中文乱码问题该如何解决(乱码问题完美解决方案)

    2024-01-13 20:06:12
  • 深入mysql主从复制延迟问题的详解

    2024-01-26 09:55:11
  • python 存储json数据的操作

    2022-10-02 13:14:14
  • Python-Selenium自动化爬虫

    2021-04-04 10:55:39
  • 交互设计中的“007功能”

    2007-10-29 11:53:00
  • php5.2 Json不能正确处理中文、GB编码的解决方法

    2023-10-26 13:49:28
  • 处理SQL Server 2000的命名实例和多实例

    2009-01-19 13:28:00
  • JavaScript编写推箱子游戏

    2024-03-17 17:47:32
  • 解决pycharm安装后代码区不能编辑的问题

    2022-07-26 22:26:24
  • asp之家 网络编程 m.aspxhome.com