您的位置:首页技术开发ASP技巧 → 怎样把数据库结构显示出来的源代码

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

时间:2004/11/7 4:11:00来源:本站整理作者:蓝点我要评论(0)

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



要查看此演示,需要你建立一个数据源,request("table")改为你的表的名字。





main







欢迎查看chenyangasp演示程序





<%

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

%>























<%sql="select * from ["&table&"] "

set rs=con.execute(sql)

for i=0 to rs.fields.count-1

%>









//字段长度







//是否允许空值







//是否为自动编号







//主健





<%next %>



字段




类型




设定大小




允许空值




自动编号

主键


<%=rs(i).name%>


//字段名





<%

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%>

//字段类型





<%=rs(i).definedsize%>






<%

attrib=rs(i).attributes

if (attrib and adFldIsNullable)=0 then

response.write "No"

else

response.write "Yes"

end if

%>







<%if rs(i).Properties("ISAUTOINCREMENT") = True then%>



<%else%>



<%end if%>







<%if rs(i).name=primarykey then%>



<%else%>



<%end if%>












相关阅读 Windows错误代码大全 Windows错误代码查询激活windows有什么用Mac QQ和Windows QQ聊天记录怎么合并 Mac QQ和Windows QQ聊天记录Windows 10自动更新怎么关闭 如何关闭Windows 10自动更新windows 10 rs4快速预览版17017下载错误问题Win10秋季创意者更新16291更新了什么 win10 16291更新内容windows10秋季创意者更新时间 windows10秋季创意者更新内容kb3150513补丁更新了什么 Windows 10补丁kb3150513是什么

文章评论
发表评论

热门文章 没有查询到任何记录。

最新文章 VB.NET 2005编写定时关 Jquery get/post下乱码解决方法 前台gbk gb如何使用数据绑定控件显示数据ASP脚本循环语句ASP怎么提速

人气排行 轻松解决"Server Application Error"和iis"一起学习DataGridView调整列宽用ASP随机生成文件名的函数Jquery get/post下乱码解决方法 前台gbk gbODBC Drivers错误80004005的解决办法返回UPDATE SQL语句所影响的行数的方法用Javascript隐藏超级链接的真实地址两个不同数据库表的分页显示解决方案