ODB ERROR 80040e14 ASP CLASSIC

时间:2015-01-07 22:02:37

标签: html mysql sql asp-classic

我的代码出了什么问题?继续显示此错误消息

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[MySQL][ODBC 5.2(w) Driver][mysqld-5.5.28-log]You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version for the right syntax
to use near ''' at line 1

/login/update2.asp, line 12 

Line 12 Set rs = objRS.Execute(mySQL)

    <%
    DIM strUsername
    strUsername = Request.Form("Username")
    IF strUsername <> "" THEN
    %>

    <%
    DIM mySQL, objRS 
    mySQL = "SELECT username, email_addr  FROM medacist_user WHERE username = " & strUsername & " ' "
    Set objRS = Server.CreateObject("ADODB.Connection")
    objRS.Open "Provider=MSDASQL.1;Password=langas;Persist Security Info=True;User ID=mmsg;Data Source=mmsg_web"   
    Set rs = objRS.Execute(mySQL)

    IF objRS.EOF THEN
    Response.Write "<div align='center'>Sorry, that username does not exist. Please click back on your browser and enter a different username.</div>"

    ELSE
    %>

    <form name="UpdatePassword" method="post" action="reset_form.asp">
    <table>
    <tr><td>Customer:</td><td>
    <input type="text" name="Username" size="50" value='<%=objRS("Username")%>'>
    </td></tr>
    <tr><td>Password:</td><td>
    <input type="text" name="Password" size="50" value='<%=objRS("Password")%>'>
    </td></tr>
    </table>
    <input type="submit" name="Submit" value="Submit">
    </form>

    <%
    END IF

    objRS.Close
    Set objRS = Nothing
    %>

    <%
    ELSE
    Response.Write "Please click back on your browser and enter your username."
    END IF
    %>

1 个答案:

答案 0 :(得分:2)

mySQL = "SELECT username, email_addr  FROM medacist_user WHERE username = '" & strUsername & " ' "

你添加了末尾撇号来指定字符串而不是起始字符串。