asp源码如何显示数据库字段的结构?
发布时间:2010-06-08 09:35:00
如何显示数据库的结构?
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body bgcolor="#CCCCCC" text="#000000">
<h2 align="center">asp教程之查看数据库结构 - www.aspxhome.com</h2>
<p>
<%
on error resume next
table=request("table")
' 获得表名
if table<>"" then
response.write "数据表:"&table
Set primary = con.OpenSchema(adSchemaPrimaryKeys, _
Array(empty, empty, table))
if primary("COLUMN_NAME")<>"" then
primarykey=primary("COLUMN_NAME")
end if
primary.close
set primary=nothing
%>
</p>
<center>
<table width="650" border="1" cellpadding="0" cellspacing="0">
<tr bgcolor="#CCCCCC">
<th class="sundog" width="61">
<div align="center">字段</div>
</th>
<th class="sundog" width="131">
<div align="center">类型</div>
</th>
<th class="sundog" width="105">
<div align="center">设定大小</div>
</th>
<th class="sundog" width="69">
<div align="center">允许空值</div>
</th>
<th class="sundog" width="69">
自动编号
</th>
<th class="sundog" width="81">主键</th>
</tr>
<%sql="select * from ["&table&"] "
set rs=con.execute(sql)
for i=0 to rs.fields.count-1
%>
<tr bgcolor="#CCCCCC">
<td class="sundog" height="2" width="61">
<div align="center"><%=rs(i).name%></div>
----------------------------------------------------------------------------------------------------------------
' 字段名
</td>
<td class="sundog" height="2" width="131">
<div align="center">
<%
field_type=rs(i).type
select case field_type
case adEmpty
typ = "Empty"
case adTinyInt
typ = "TinyInt"
case adSmallInt
typ = "SmallInt"
case adInteger
typ = "Integer"
case adBigInt
typ = "BigInt"
case adUnsignedTinyInt
typ = "UnsignedTinyInt"
case adUnsignedSmallInt
typ = "UnsignedSmallInt"
case adUnsignedInt
typ = "UnsignedInt"
case adUnsignedBigInt
typ = "UnsignedBigInt"
case adSingle
typ = "Single"
case adDouble
typ = "Double"
case adCurrency
typ = "Currency"
case adDecimal
typ = "Decimal"
case adNumeric
typ = "Numeric"
case adBoolean
typ = "Boolean"
case adError
typ = "Error"
case adUserDefined
typ = "UserDefined"
case adVariant
typ = "Variant"
case adIDispatch
typ = "IDispatch"
case adIUnknown
typ = "IUnknown"
case adGUID
typ = "GUID"
case adDATE
typ = "DATE"
case adDBDate
typ = "DBDate"
case adDBTime
typ = "DBTime"
case adDBTimeStamp
typ = "DBTimeStamp"
case adBSTR
typ = "BSTR"
case adChar
typ = "Char"
case adVarChar
typ = "VarChar"
case adLongVarChar
typ = "LongVarChar"
case adWChar
typ = "WChar"
case adVarWChar
typ = "VarWChar"
case adLongVarWChar
typ = "LongVarWChar"
case adBinary
typ = "Binary"
case adVarBinary
typ = "VarBinary"
case adLongVarBinary
typ = "LongVarBinary"
case adChapter
typ = "Chapter"
case adPropVariant
typ = "PropVariant"
case else
typ = "Unknown"
----------------------------------------------------------------------------------------------------------------
end select
response.write typ%>
' 字段类型
</div>
</td>
<td class="sundog" height="2" width="105">
<div align="center"><%=rs(i).definedsize%></div>
</td>
' 字段长度
<td class="sundog" height="2" width="69">
<div align="center">
<%
attrib=rs(i).attributes
if (attrib and adFldIsNullable)=0 then
response.write "No"
else
response.write "Yes"
end if
%>
</div>
</td>
----------------------------------------------------------------------------------------------------------------
' 是否允许空值
<td class="sundog" height="2" width="69">
<div align="center">
<%if rs(i).Properties("ISAUTOINCREMENT") = True then%>
<input type="checkbox" name="autoincrement" value="checkbox" checked>
<%else%>
<input type="checkbox" name="autoincrement" value="checkbox">
<%end if%>
</div>
</td>
----------------------------------------------------------------------------------------------------------------
' 是否为自动编号
<td class="sundog" height="2" width="81">
<div align="center">
<%if rs(i).name=primarykey then%>
<input type="checkbox" name="primarykey" value="checkbox" checked>
<%else%>
<input type="checkbox" name="primarykey" value="checkbox">
<%end if%>
</div>
</td>
----------------------------------------------------------------------------------------------------------------
' 主健
</tr>
<%next %>
</table>
</center>
猜你喜欢
- 任何一个行业里,当有一头近乎垄断的大象盘踞着的时候,生活在大象身后的蚂蚁们既是悲哀又是幸运的。悲哀的是市场已近乎被大象垄断留给他们的空间已经
- 这不是什么原创,是我跟据OReilly.JavaScript.The.Definitive.Guide.5th.Edition.Aug.20
- SQL Server数据库涉及到的数据仓库概念:1.多维数据集:多维数据集是联机分析处理 (OLAP) 中的主要对象,是一项可对数据仓库中的
- HTML5 中 div section article 的区别刚刚开始接触 HTML5 时,对它的标签很不适应,甚至一度有点反感。尤其是对
- 一直以来,每次调用Ajax方法都需要创建一次 Microsoft.XMLHTTP 对象,今天在使用Ajax技术做一个类似聊天室的
- 在页面中自定义了changejs函数后页面提示错误:Active Server Pages 错误 'ASP 0138' 嵌套
- 在Microsoft OfficeAccess和 Microsoft OfficeExcel之间存在多种交换数据的方法。若要将Access中
- 快捷键可以帮助我们有效提高效率,我们来看看网页设计软件FrontPage有哪些快捷键。相关文章:Dreamweaver快捷键大全、photo
- asp定时生成静态HTML的代码,对于缓解服务器压力有很大帮主,需要的朋友可以参考下。<% '判断是否要生成新的HT
- 在Google Reader上看到网友分享的一个链接,真的发现自己已经out了。上面的这张图,是纯CSS实现的,没有背景图、没有Javasc
- ASP开发中有用的function集合,挺有用处的!希望大家保留!<% '**
- 你是否有时想知道什么人访问你的站点,什么时间,IP地址等。下面我就这个问题向大家来阐述一下。这个例子使用文本文件来写入用户的信息创建一个lo
- 蓝色混迹多年,偷师学艺不少,这次花了2天时间写了点东西发出来送给需要的吧。先放个图片,我改下代码。 重构完成 IE 6 
- 方法1: X:\oracle\ora81\bin\wrap iname=XXX oname=XXX 方法2:9i在win2000下使用wra
- 本期薯片会的目的是讨论人物角色在设计中如何应用的问题。围绕了以下几个问题开展了讨论:1、 角色能干什么?2、 包含哪
- CSS2.1 中规定了关于 CSS 规则 Specificity(特异性)的计算方式,用一个四位的数字串(注:CSS2 中是用三位)来表示,
- 4款JavaScript放大镜特效脚本。准确的说,Anythingzoomer和Bezoom才是正宗的放大镜特效,当鼠标悬浮在图片上时,能放
- 最近被“模块化”缠身,又是文章又是PPT的,被逼着想了很多相关的东西。整理下我这段时间对于“模块化”的思考,大多都是我自己从事页面重构这份工
- 因工作需要,要将存放在sql server数据库中的数据全部导入到mysql数据库中,在网上搜集相关资料,找到两种方法,现在分别谈谈对他们的
- 很多的朋友一而再,再而三的在Server.Mappath上卡壳,cnbruce也是一遍两遍地重复,还是不能全部解决,所以通过下面的举例,希望