欢迎光临
我们一直在努力

怎样把数据库结构显示出来的源代码

建站超值云服务器,限时71元/月

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

要查看此演示,需要你建立一个数据源,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>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 怎样把数据库结构显示出来的源代码
分享到: 更多 (0)