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
投稿

猜你喜欢

  • python面试题小结附答案实例代码

    2021-05-04 13:13:08
  • PL/SQL number型数据

    2009-02-26 10:59:00
  • Python使用os.listdir和os.walk获取文件路径

    2023-01-30 11:02:10
  • Can't connect to MySQL server on 'localhost' (10048)问题解决方法

    2024-01-19 06:58:47
  • Python实例练习水仙花数问题讲解

    2023-05-26 18:38:11
  • django实现将修改好的新模型写入数据库

    2024-01-28 19:50:13
  • Python中的内置函数isdigit()

    2023-05-16 16:10:31
  • Python字符串的创建和驻留机制详解

    2022-07-07 18:49:17
  • 详解利用装饰器扩展Python计时器

    2023-04-08 20:32:16
  • Mac OS下PHP环境搭建及PHP操作MySQL常用方法小结

    2024-05-08 10:16:31
  • 优化mysql的limit offset的例子

    2024-01-12 17:23:25
  • 使用pycharm运行flask应用程序的详细教程

    2022-12-15 05:15:55
  • 详解django+django-celery+celery的整合实战

    2022-11-14 12:25:13
  • 详解Mysql case then使用

    2024-01-25 05:38:19
  • PHP PDOStatement::errorCode讲解

    2023-06-11 12:40:23
  • 在Python中使用Neo4j数据库的教程

    2024-01-15 00:40:54
  • python QT界面关闭线程池的线程跟随退出完美解决方案

    2023-01-01 11:56:21
  • GraphQL在Django中的使用教程

    2023-02-20 18:11:31
  • Django 实现前端图片压缩功能的方法

    2022-11-05 09:05:16
  • jupyter notebook内核启动失败问题及解决方法

    2022-09-21 02:31:04
  • asp之家 网络编程 m.aspxhome.com