答案:<%
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>"
%>
上一个:odbc和ole db在连接数据库时有什么区别?
下一个:SQL Server静态页面导出技术(SQL Server Web Assistant)