我有一个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并重写它,但想知道我是否错过了一些明显的东西!
由于
答案 0 :(得分:1)
如果没有错误消息,我会发现两个潜在的问题:
首先,ID
可能是MySQL中的保留字以及错误或两个错误的原因。详细的错误消息将指示这是否是问题。
其次,看起来您最终可能会得到一个包含两个FROM
子句的SQL语句。 Response.Write
SQL并检查发送到服务器的语句。编辑您的问题以包含它。