我该如何运行下面的代码?

时间:2015-06-25 05:27:08

标签: sql sql-server asp-classic

我写了这些代码来在线管理我的mssql数据库,但它没有用。我的错是什么?我试过,但我找不到自己的错。你能帮我吗?任何帮助将不胜感激......

<%@LANGUAGE="VBSCRIPT"%>
<%page = Request.Querystring("page")%>
<!doctype html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>Sql Statement</title>
    </head>

    <body>
        <form method="post" action="?page=run">
            <input type="text" name="code" size="100">
            <input type="submit" name="run" value="run">
        </form>
        <% if page = "error" then %>
            <p><b>Error!</b></p>
        <% end if %>
        <% if page = "thanks" then %>
            <p>Ok!</p>
        <% end if %>

        <% 
        if page="run" then
            code = Request.form("code")
            On Error Resume Next 

            StrDB = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _ 
            Server.MapPath("database/data.mdb" ) 

            Set StrConn = Server.CreateObject("ADODB.Connection" ) 
            StrConn.Open StrDB 

            Set recordset = StrConn.Execute(code)

            If Err <> 0 Then 
                Response.redirect "?page=error" 
            Else 
                Response.redirect "?page=thanks" 
            End If 

            StrConn.Close 
            Set StrConn = Nothing 
        End IF
        %>

    </body>
</html>

1 个答案:

答案 0 :(得分:0)

您可以尝试将以下代码放在页面顶部

page = Request.Querystring("page")