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> 

标签:数据库,结构,asp
0
投稿

猜你喜欢

  • SQL Server如何保证可空字段中非空值唯一

    2011-02-24 16:44:00
  • 基于ExtJs框架的B/S高级查询界面

    2008-10-07 18:05:00
  • 细化解析:轻松掌握怎样测试 MySQL安装

    2009-01-14 11:54:00
  • 改善登陆界面的用户体验: 自动聚焦表单

    2009-12-09 16:13:00
  • 在HTML中,常见的URL有多种表示方式:

    2009-07-28 12:18:00
  • 获取一个数字的个位、十位、百位的函数代码

    2011-02-20 11:06:00
  • 从HTTP状态 301,302,200 来看页面跳转

    2007-09-26 13:46:00
  • Microsoft Access 数据库常规规格

    2007-09-27 19:28:00
  • 贝聿铭写给年轻设计师的十点忠告

    2010-01-24 18:46:00
  • 在Oracle网络结构解决连接问题

    2010-07-28 12:49:00
  • 二级联动下拉菜单javascript源码

    2010-03-16 12:32:00
  • oracle下加密存储过程的方法

    2009-02-28 10:50:00
  • ASP格式化日期的函数(输出13种样式)

    2011-07-12 20:22:00
  • MySQL聚焦Web 2.0可扩展性

    2012-01-05 19:02:19
  • ASP中Session技巧 默认过期时间为20分钟

    2012-12-04 20:28:26
  • oracle sqlplus 常用命令大全

    2009-05-24 19:47:00
  • 小议javascript设计模式

    2009-10-09 13:31:00
  • SQL 注入式攻击的终极防范

    2011-04-03 11:21:00
  • FrontPage XP设计教程2——网页的编辑

    2008-10-11 12:16:00
  • MySQL 数据编码 latin1 转 UTF8

    2010-10-14 14:20:00
  • asp之家 网络编程 m.aspxhome.com