·您的位置: 首页 » 资源教程 » 编程开发 » ASP » 在ASP中列出数据库中的表名和字段名的程序

在ASP中列出数据库中的表名和字段名的程序

类别: ASP教程  评论数:0 总得分:0
<%
dsn = "DSN=DSNName"
Const adSchemaTables = 20
adSchemaColumns = 4
Set oConn = Server.CreateObject("ADODB.Connection")

oConn.open dsn
Set rstSchema = oConn.OpenSchema(adSchemaColumns)
response.write "<table>"
response.write "<tr><td>Table name</td><td>field name</td><td>field type</td><td>is nullable</td><td>field size</td></tr>"
tablename=""
Do Until rstSchema.EOF
response.write "<tr><td>"
if rstSchema("Table_name") <> tablename then
response.write rstSchema("Table_name")
tablename = rstSchema("Table_name")
else
response.write " "
end if
response.write "</td><td>"& rstschema("column_Name") & "</td><td>"
select case rstschema("data_type")
case "130"
if rstschema("CHARACTER_MAXIMUM_LENGTH") = 1073741823 then
response.write "Memo"
else
response.write "Text"
end if
case 135
response.write "Date/Time"
case 3
response.write "Long Integer"
case 11
response.write "Yes/No"
case 131
response.write "Currency"
case else
response.write rstschema("data_type")
end select
response.write "</td><td>" & rstschema("is_nullable") & "</td><td>"
if rstschema("CHARACTER_MAXIMUM_LENGTH") <> 1073741823 then
response.write rstschema("CHARACTER_MAXIMUM_LENGTH")
else
response.write " "
end if
response.write "</td></tr>"
rstSchema.MoveNext
Loop
response.write "</table>"
%>
-= 资 源 教 程 =-
文 章 搜 索
关键词:
类型:
范围:
纯粹空间 softpure.com
Copyright © 2006-2008 暖阳制作 版权所有
QQ: 15242663 (拒绝闲聊)  Email: faisun@sina.com
 纯粹空间 - 韩国酷站|酷站欣赏|教程大全|资源下载|免费博客|美女壁纸|设计素材|技术论坛   Valid XHTML 1.0 Transitional
百度搜索 谷歌搜索 Alexa搜索 | 粤ICP备19116064号-1