怎样在ASP中列出数据库中的表名和字段名的程序
展开全部
<%
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>"
%>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询