SQL Query syntax error within ASP file.

Discussion in 'C#' started by theshad_ow, Jul 31, 2008.

  1. #1
    Hi guys, Below is my asp page; I am getting an error on the server (Error Type:
    Microsoft JET Database Engine (0x80040E14)
    Syntax error (missing operator) in query expression 'memberid ='.
    /owace/main.asp, line 66)

    I believe I am missing some quote or something.

    Line 61-66 is in yellow at the bottom. The line in orange color has some syntax issue. Please if someone can fix this. Thanks!

    <!--#include file="incGlobal.asp"-->
    <!--#INCLUDE FILE="connection.asp" -->

    <head>
    <LINK href="../css/table_items.css" type=text/css rel=stylesheet>
    <script language="JavaScript" src="royale.js"></script>
    </head>
    <body>


    <div align=center >
    <p style="margin-top: 0; margin-bottom: 0">
    <img border="0" src="../images/royale_grande_admin_logo.jpg"></p>
    <p style="margin-top: 0; margin-bottom: 0">&nbsp;</p>
    <p style="margin-top: 0; margin-bottom: 0"><%Response.Write apartName %> &nbsp; Board of Directors
    Administration Page</p>
    </div>

    <p style="margin-top: 0; margin-bottom: 0">&nbsp;</p>

    <div align=center >
    <table>
    <tr>

    <td><b>
    CAT ID&nbsp;</b>
    &nbsp;
    </td>

    <td width="493" height="19">MEMBERS&nbsp;
    &nbsp;
    </td>

    <td width="78" height="19">PASSWORD
    </td>

    </tr>

    <%

    DIM strOrderBy, tmpOrderBy
    strOrderBy = Request.QueryString("OB")
    Select Case strOrderBy

    Case "catid_desc"
    tmpOrderBy = "ORDER BY cat_id DESC"
    Case "catid_asc"
    tmpOrderBy = "ORDER BY memberID ASC"
    Case "cat_desc"
    tmpOrderBy = "ORDER BY cat_name DESC"
    Case "cat_asc"
    tmpOrderBy = "ORDER BY cat_name ASC"



    End Select

    roleid = Request( "roleid" )
    memberid = Request( "memberid" )

    DIM mySQL, objRS, mySQL2, objRS2
    'mySQL = "SELECT * FROM board_members"
    mySQL = "SELECT * FROM board_members ORDER BY memberID ASC"
    mySQL2 = "SELECT * FROM board_members where memberid = " & cstr(memberid)
    Set objRS2 = Server.CreateObject("ADODB.Recordset")
    objRS2.Open mySQL2, objConn

    Set objRS = Server.CreateObject("ADODB.Recordset")
    objRS.Open mySQL, objConn

    roleid = Request( "roleid" )

    if roleid = "3" then
    response.redirect("cat.asp?catid=" & memberID & "&apartName=" & objRS2("apart_name") & "&apartdir=" & objRS2( "apart_directory" ) & "&roleid=" & objRS2("User_Role" ))



    end if

    Do UNTIL objRS.EOF

    %>
    <tr>
    <td>
    <%=objRS( "memberID" )%></td>
    <td><a href="cat.asp?catid=<%=objRS( "memberID" )%>&apartName=<%=objRS("apart_name")%>&apartdir=<%=objRS( "apart_directory" )%>&roleid=<%=objRS("User_Role" )%>"><%=objRS("apart_name")%></a></td>
    <td>
    <%=objRS("apart_password")%>&nbsp;&nbsp;
    <a href="updatepass.asp?catid=<%=objRS( "memberID" )%>&apartName=<%=objRS("apart_name")%>&apartPassword=<%=objRS("apart_password")%>&updatePass=1')">
    [change]</a>
    </td>
    </tr>

    <%


    objRS.MoveNext
    Loop
    %>

    </div>
    </table>

    <table width="100" border="1">
    <tr>
    <td><a href="form.htm">Create Users</a></td>
    </tr>
    </table>
    Edit/Delete Message
     
    theshad_ow, Jul 31, 2008 IP
  2. VishalVasani

    VishalVasani Peon

    Messages:
    560
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hello,

    Change following code in your file
    
    roleid = replace(Request( "roleid" ),"'","''")
    memberid = replace(Request( "memberid" ),"'","''")
    
    Code (markup):
    Replace ' with '' quotes
     
    VishalVasani, Jul 31, 2008 IP
  3. theshad_ow

    theshad_ow Peon

    Messages:
    23
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    thanks but still same error.
     
    theshad_ow, Aug 1, 2008 IP
  4. vihutuo

    vihutuo Well-Known Member

    Messages:
    1,511
    Likes Received:
    34
    Best Answers:
    0
    Trophy Points:
    180
    #4
    Two possible problems

    1. If memberid is stored as a string in the database then change
    mySQL2 = "SELECT * FROM board_members where memberid = " & cstr(memberid)
    to
    mySQL2 = "SELECT * FROM board_members where memberid = '" & cstr(memberid) & "'"

    2. In the line
    memberid = Request( "memberid" )
    Are u sure Request( "memberid" ) is not empty or null ?
    Verify that Request( "memberid" ) contains a value

    Hope it helps
     
    vihutuo, Aug 4, 2008 IP
  5. adsenseblog

    adsenseblog Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    i think the error is from this.

    mySQL2 = "SELECT * FROM board_members where memberid = '" & cstr(memberid)

    make it as vihutuo said:
    mySQL2 = "SELECT * FROM board_members where memberid = '" & cstr(memberid) & "'"

    it will help you
     
    adsenseblog, Aug 8, 2008 IP