0

我有一个 asp 内网系统,我需要将 Access DB 后端更改为 MySQL,Access DB 只是用于与 sql 表类似的结构。我创建了具有相同结构和命名约定的 sql 表。

ASP Classic 应用程序有一个文件夹,其中包含连接到每个单独数据库的连接,有 8 个 Access DB,现在合并为 1 个 MySQL 数据库中的表。

我在浏览器中显示错误消息时遇到问题,即使在将错误页面设置为在 IIS7 中远程显示后也出现内部错误

旧连接:

            <%
            Dim MM_Employee_STRING
            MM_Employee_STRING = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Server.MapPath("/employee/DB/employee.mdb")
            %>

新连接:

            <%
            Dim MM_Employee_STRING
            MM_Employee_STRING = "DRIVER={MySQL ODBC 5.2};SERVER=localhost;UID=root;PWD=password;DATABASE=db")
            %>

登录 Asp 代码:

            MM_LoginAction = Request.ServerVariables("URL")
            If Request.QueryString<>"" Then MM_LoginAction = MM_LoginAction + "?" + Server.HTMLEncode(Request.QueryString)
            MM_valUsername=CStr(Request.Form("UserName"))
            If MM_valUsername <> "" Then
              MM_fldUserAuthorization="securityLevel"
              MM_fldUserRaisedID="RaisedNameID"
              MM_redirectLoginSuccess="index.asp"
              MM_redirectLoginFailed="error.asp"
              MM_flag="ADODB.Recordset"
              set MM_rsUser = Server.CreateObject(MM_flag)
              MM_rsUser.ActiveConnection = MM_Employee_STRING
              MM_rsUser.Source = "SELECT LoginUsername, LoginPassword, ID FROM employee_detail"
              If MM_fldUserAuthorization <> "" Then MM_rsUser.Source = MM_rsUser.Source & "," & MM_fldUserAuthorization & "," & MM_fldUserRaisedID
              MM_rsUser.Source = MM_rsUser.Source & " FROM employee_detail WHERE LoginUsername='" & Replace(MM_valUsername,"'","''") &"' AND LoginPassword='" & Replace(Request.Form("Password"),"'","''") & "'"
              MM_rsUser.CursorType = 0
              MM_rsUser.CursorLocation = 2
              MM_rsUser.LockType = 3
              MM_rsUser.Open
              If Not MM_rsUser.EOF Or Not MM_rsUser.BOF Then 
                ' username and password match - this is a valid user
                Session("MM_Username") = MM_valUsername
                If (MM_fldUserAuthorization <> "") Then
                  Session("MM_UserAuthorization") = CStr(MM_rsUser.Fields.Item(MM_fldUserAuthorization).Value)
                  Session("MM_UserID") = MM_rsUser.Fields.Item("ID").Value
                  Session("MM_RaisedUserID") = MM_rsUser.Fields.Item("RaisedNameID").Value
                Else
                  Session("MM_UserAuthorization") = ""
                End If
                if CStr(Request.QueryString("accessdenied")) <> "" And false Then
                  MM_redirectLoginSuccess = Request.QueryString("accessdenied")
                End If
                MM_rsUser.Close
                Response.Redirect(MM_redirectLoginSuccess)
              End If
              MM_rsUser.Close
              Response.Redirect(MM_redirectLoginFailed)
            End If

就 ASP 而言,我从未接触过它,我即将将其全部转换为 ASP.Net 并重写它,但想知道我是否遗漏了一些明显的东西!

谢谢

4

1 回答 1

1

如果没有错误消息,我会看到两个潜在问题:

首先,ID可能是 MySQL 中的保留字和一两个错误的原因。详细的错误消息将指示这是否是问题所在。

其次,看起来您最终可能会得到一个包含两个FROM子句的 SQL 语句。Response.WriteSQL 并检查正在发送到服务器的语句。编辑您的问题以包含它。

于 2013-10-02T18:00:10.120 回答