设为首页
加入收藏
帮助中心
首页 | 红盾通告 | 信息中心 | ASP技术 | 数据库 | 网页设计 | 网管专栏 | OICQ攻略 | 墨客频道 | 网站运营 |
当前位置:首页 >> 数据库 >> SQL Server >> 正文
最新信息
·SQL2000做附加数据库时报:…
·数据库sql被挂马终极批量删…
·动网论坛全文索引建立帮助
·论坛不支持文章内容搜索的…
·打造抵御SQL注入攻击的MSS…
·10个保护SQL Server 2000安…
·sql server安全设置攻略
·SQL Server安全设置清单列…
·使用 SQL Server 时需要经…
·SQL中触发器实例讲解
资料搜索
热点信息
·如何压缩SQL Server 2000数…
·SQL中触发器实例讲解
·日志文件满而造成SQL数据库…
·10个保护SQL Server 2000安…
·使用 SQL Server 时需要经…
·SQL2000做附加数据库时报:…
·SQL SERVER的安全隐患:触…
·asp如何连接sql server并实…
·SQL Server不能启动的常见…
·一种简单的表中删除重复行…
推荐信息
·打造抵御SQL注入攻击的MSS…
·SQL Server数据库开发的二…
·Sqlserver 优化的方法
·SQLServer吞噬的内存解决办…
·SQL SERVER日志清除的两种…
·如何压缩SQL Server 2000数…
·SQL Server 2000 SP4发布
·动网论坛全文索引建立帮助
·10个保护SQL Server 2000安…
·SQL Server安全设置清单列…


Google
 
怎样把数据库结构显示出来的源代码
〖编辑:Cloudy | 浏览:人次〗

通过以上的代码即可显示表的结构,字段类型,长度,自动编号,主健。如果你仔细研究后就可以发现如何远程改变数据库的结构了,祝你好运!

要查看此演示,需要你建立一个数据源,request("table")改为你的表的名字。
<html>
<head>
<title>main</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body bgcolor="#CCCCCC" text="#000000">
<h2 align="center"><font face="华文新魏">欢迎查看chenyangasp演示程序</font></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>


录入时间:2007-02-08 10:59:11 [打印本页] [关闭窗口] [返回顶部]
特别声明: 本站除部分特别声明禁止转载的专稿外的其他文章可以自由转载,但请务必注明出处和原始作者。文章版权归文章原始作者所有。对于被本站转载文章的个人和网站,我们表示深深的谢意。如果本站转载的文章有版权问题请联系编辑人员,我们尽快予以更正。

Copyright © 2006-2014 0733168.Com Inc All Rights Reserved
关于我们 | 广告合作 | 联系我们 | 法律声明 | 友情链接 | 意见反馈
本站所收录信息、社区话题、及本站所做之广告均属其个人行为,与本站立场无关
湘ICP备06008436号