欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

显示sql数据库所有表的名称(带删除功能)

程序员文章站 2022-12-05 10:06:25
<% define your sql info herestrsqldsn = "xxxx"strsqlusername = "sa"strsqlpassword = ""...
<%
define your sql info here
strsqldsn = "xxxx"
strsqlusername = "sa"
strsqlpassword = ""

this is where we connect to our sql server(windows平台上强大的平台)
set adoconn = server.createobject("adodb.connection")
connectionstring = "dsn=" & strsqldsn & ";uid=" & strsqlusername & ";pwd=" & strsqlpassword & ""
adoconn.open connectionstring
set adors = server.createobject("adodb.recordset")

now we will just difine a couple things
showblank = "&nbsp;"
shownull = "-null-"

if request.querystring("action") = "del" then
    delete_data
else
    if request.querystring("table") <> "" then
         a table has been selected
        page_head
        display_table_names
        if request.querystring("msg") = "deleted" then
            response.write("<p><br></p>")
            response.write("<font color=""#ff0000""><b>成功删除数据</b></font>")
        else
            response.write("<p><br></p>")
        end if
        display_table_info
    else
         no table has been selected.
        page_head
        display_table_names
    end if
end if

sub page_head
%>
<html>
<head>
<title>sql viewer</title>
<body alink=#0663bf leftmargin="0" link="#0663bf" topmargin="0" vlink="#0663bf" marginheight="0"

marginwidth="0">
</head>
<p><br></p>
<%
end sub

sub delete_data
    strsql = "delete from " & request.querystring("table") & " where id=" &

request.querystring("id") & ""
    set adors = adoconn.execute(strsql)
    strurl = "index.?table=" & request.querystring("table") & "&msg=deleted"
    response.redirect(strurl)
end sub

sub display_table_names
    response.write("<p align=""center""><center>" & vbcrlf)
    response.write("" & vbcrlf)
    response.write("<table border=""1"" cellpadding=""0"" cellspacing=""0"" width=""36%""

bordercolor=""#9b9180"">" & vbcrlf)
    response.write("  <tr bgcolor=""#9b9180"">" & vbcrlf)
    response.write("    <td width=""100%""><p align=""center""><font

color=""#ffffff""><strong>sql viewer</strong></font></td>" & vbcrlf)