如何显示 SQL 数据库所有表的名称? <% strSQLDSN = "xxxx" strSQLUsername = "sa" strSQLPassword = "" ' 定义数据库相关信息 Set adoConn = Server.CreateObject("ADODB.Connection") ConnectionString = "dsn=" & strSQLDSN & ";uid=" & strSQLUsername & ";pwd=" & strSQLPassword & "" adoConn.Open ConnectionString Set adoRS = Server.CreateObject("ADODB.Recordset") ' 连接我们的数据库 showblank = " " shownull = "-null-" ' 定义这一对儿 If Request.QueryString("action") = "del" Then Delete_Data Else If Request.QueryString("table") <> "" Then ' 已选择一个表 Page_Head Display_Table_Names If Request.QueryString("msg") = "deleted" Then Response.Write("

") Response.Write("成功删除数据") Else Response.Write("

") End If Display_Table_Info Else ' 没有表被选中 Page_Head Display_Table_Names End If End If Sub Page_Head %>

<% End Sub Sub Delete_Data strSQL = "Delete From " & Request.QueryString("table") & " Where ID='" & Request.QueryString("id") & "'" Set adoRS = adoConn.Execute(strSQL) strURL = "index.asp?table=" & Request.QueryString("table") & "&msg=deleted" Response.Redirect(strURL) End Sub Sub Display_Table_Names Response.Write("

" & vbCrLf) Response.Write("" & vbCrLf) Response.Write("

" & vbCrLf) Response.Write("
" & vbCrLf) Response.Write("

SQL 查看" & vbCrLf) Response.Write("
" & vbCrLf) Response.Write("
" & vbCrLf) Response.Write("

" & vbCrLf) Response.Write("
" & vbCrLf) Response.Write("	" & vbCrLf) Response.Write("
" & vbCrLf) Response.Write("
" & vbCrLf) Response.Write("	name=""Table"" style=""font-family: Verdana; font-size: 8pt"" " & vbCrLf) Response.Write("
请选择表名进行查看.
" & vbCrLf) strSQL = "SELECT name FROM sysobjects WHERE xtype = 'U' AND (Not (id) = 133575514) ORDER BY name" Set adoRS = adoConn.Execute(strSQL) Do While Not adoRS.EOF Response.Write "
" & adoRS("name") & "
" adoRS.MoveNext Loop Response.Write(" " & vbCrLf) Response.Write("
" & vbCrLf) Response.Write("
" & vbCrLf) Response.Write("	" & vbCrLf) Response.Write("
" & vbCrLf) Response.Write("

" & vbCrLf) Response.Write("

" & vbCrLf) Response.Write("
" & vbCrLf) Response.Write("

" & vbCrLf) Response.Write("

" & vbCrLf) End Sub Sub Display_Table_Info Response.Write("

" & vbCrLf) Response.Write("

" & vbCrLf) Response.Write("
" & vbCrLf) Response.Write("

SQL 显示" & vbCrLf) Response.Write("
" & vbCrLf) Response.Write("
" & vbCrLf) Response.Write("

" & vbCrLf) Response.Write("
" & vbCrLf) Response.Write("	" & vbCrLf) Response.Write("
" & vbCrLf) Response.Write("
" & vbCrLf) strSQL="select * from " & Request.QueryString("table") & "" ' 选择我们要显示的表 set adoRS=adoConn.execute(strSQL) Response.Write("

" & vbCrLf) ' 从表开始 FOR EACH fieldname IN adoRS.fields ' 查找表里的全部字段并把它们写出来 Response.Write("	" & fieldname.name & "") NEXT ' fieldname Response.Write("	删除") Response.Write("
" & vbCrLf) DO UNTIL adoRS.eof Response.Write("
") FOR EACH fieldname IN adoRS.fields strFieldValue=fieldname.value strField=fieldname.name IF isnull(strFieldValue) THEN strFieldValue=shownull END IF IF trim(strFieldValue)="" THEN strFieldValue=showblank END IF IF strField = "ID" OR strField = "id" THEN strRecordID = strFieldValue END IF Response.Write("	" & strFieldValue & "" & vbCrLf) NEXT Response.Write("	删除 " & vbCrLf) adoRS.movenext LOOP Response.Write("

") adoRS.close Response.Write("
" & vbCrLf) Response.Write("
" & vbCrLf) Response.Write("	" & vbCrLf) Response.Write("
" & vbCrLf) Response.Write("

" & vbCrLf) Response.Write("

" & vbCrLf) Response.Write("
" & vbCrLf) Response.Write("

" & vbCrLf) Response.Write("

" & vbCrLf) End Sub %>