Syntax error in UPDATE statement- asp/jscript

Ask a Question related to ASP, Design and Development.

  1. #1

    Default Syntax error in UPDATE statement- asp/jscript

    Hi All!

    I have the following two methods in an asp/jscript page - my problem is that
    without the update statement there is no error, but with the update
    statement I get the following error:

    Error Type:
    Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
    [Microsoft][ODBC Microsoft Access Driver] Syntax error in UPDATE statement.
    /polyprint/dataEntry.asp, line 158

    I fail to understand why there is a syntax error - I am pretty sure all of
    the parameters to the Open method are ok..

    Any advice would be most welcome!

    Rob
    :)

    function modifyNewsletter()
    {
    var _newsletter = getParameter ("edition");
    var _language = getParameter ("language");

    var sql = "SELECT * " +
    "FROM newsletterText " +
    "WHERE (((newsletterText.pageName)='" + _newsletter + "') " +
    "AND ((newsletterText.language)='" + _language + "')) " +
    "order by newsletterText.paragraph asc";

    var newsletterText = getRecordSetForModifyingRecords (sql);

    while (!newsletterText.EOF)
    {
    Response.Write (newsletterText ("text") + " --- " +
    newsletterText ("style") + "<br>");

    newsletterText ("text") = "changed...";

    // problem statement
    newsletterText.Update;

    Response.Write (newsletterText ("text") + " --- " +
    newsletterText ("style") + "<br>");


    newsletterText.MoveNext();
    } // end while


    // Gets a recordset for modifying records.
    // Uses the adLockOptimistic lock and accepts an sql statement.
    function getRecordSetForModifyingRecords (sql)
    {
    var rs = Server.CreateObject ("ADODB.Recordset");
    rs.Open (sql, // Source
    polyprintConnection, // ActiveConnection
    adOpenForwardOnly, // CursorType
    adLockOptimistic); // LockType
    return rs;
    } // end getRecordSetForModifyingRecords function


    Robert Mark Bram Guest

  2. Similar Questions and Discussions

    1. Syntax error in UPDATE statement.
      ok i have an update form that i created it is for the admin of the site to add/edit user account info for memebers to login. the form adds or edits...
    2. Syntax error in INSERT INTO statement
      I have a two table setup in fact I am doing the blog tutorial on Macromedia but with Access and asp I have two tables topic and articles I have a...
    3. Syntax error in Where Statement
      Having a problem with what the server says is a syntax error in the Where statement, but cant figure out where it is. <cfif ...
    4. Syntax Error Update Statement
      Can someone tell me what's wrong with this code? I need help. Thanks! It is an update page. FIRST PAGE: LOGIN CHECK <!--- Filename: ...
    5. Syntax Error In Update Statement
      I'm having a problem getting one piece of code to work on my app. It's a simple password change. For some reason, I've been getting the following...
  3. #2

    Default Re: Syntax error in UPDATE statement- asp/jscript

    Try response.writing your variable sql to the screen and see what the lines
    says, try and post that as a query directly into access and see if it gives
    you anything.

    It could be something to do with the way you are breaking up the sql
    statement (like missing a space accidently) so put it all in one line for
    the moment might help and then when you are done, then you can break it up.

    I don't know about JS with serverside stuff, but in vbscript you should put
    something like

    sql = "SELECT * "sql = sql +
    sql = sql + "FROM newsletterText "sql = sql +
    sql = sql + "WHERE (((newsletterText.pageName)='" + _newsletter + "') "sql
    = sql +
    sql = sql + "AND ((newsletterText.language)='" + _language + "')) "sql =
    sql +
    sql = sql + "order by newsletterText.paragraph asc"

    Not saying any of these things are the prob, but may help trouble shoot the
    issues you are seeing.

    Good luck

    Stu



    "Robert Mark Bram" <relaxedrob@removethis.optushome.com.au> wrote in message
    news:3f9518d0$0$9554$afc38c87@news.optusnet.com.au ...
    > Hi All!
    >
    > I have the following two methods in an asp/jscript page - my problem is
    that
    > without the update statement there is no error, but with the update
    > statement I get the following error:
    >
    > Error Type:
    > Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
    > [Microsoft][ODBC Microsoft Access Driver] Syntax error in UPDATE
    statement.
    > /polyprint/dataEntry.asp, line 158
    >
    > I fail to understand why there is a syntax error - I am pretty sure all of
    > the parameters to the Open method are ok..
    >
    > Any advice would be most welcome!
    >
    > Rob
    > :)
    >
    > function modifyNewsletter()
    > {
    > var _newsletter = getParameter ("edition");
    > var _language = getParameter ("language");
    >
    > var sql = "SELECT * " +
    > "FROM newsletterText " +
    > "WHERE (((newsletterText.pageName)='" + _newsletter + "') "
    +
    > "AND ((newsletterText.language)='" + _language + "')) " +
    > "order by newsletterText.paragraph asc";
    >
    > var newsletterText = getRecordSetForModifyingRecords (sql);
    >
    > while (!newsletterText.EOF)
    > {
    > Response.Write (newsletterText ("text") + " --- " +
    > newsletterText ("style") + "<br>");
    >
    > newsletterText ("text") = "changed...";
    >
    > // problem statement
    > newsletterText.Update;
    >
    > Response.Write (newsletterText ("text") + " --- " +
    > newsletterText ("style") + "<br>");
    >
    >
    > newsletterText.MoveNext();
    > } // end while
    >
    >
    > // Gets a recordset for modifying records.
    > // Uses the adLockOptimistic lock and accepts an sql statement.
    > function getRecordSetForModifyingRecords (sql)
    > {
    > var rs = Server.CreateObject ("ADODB.Recordset");
    > rs.Open (sql, // Source
    > polyprintConnection, // ActiveConnection
    > adOpenForwardOnly, // CursorType
    > adLockOptimistic); // LockType
    > return rs;
    > } // end getRecordSetForModifyingRecords function
    >
    >

    Stuart Palmer Guest

  4. #3

    Default Re: Syntax error in UPDATE statement- asp/jscript

    Where's line 158? And what does Response.write(sql) show you for the SQL
    query just before that line?

    Ray at work

    "Robert Mark Bram" <relaxedrob@removethis.optushome.com.au> wrote in message
    news:3f9518d0$0$9554$afc38c87@news.optusnet.com.au ...
    > Hi All!
    >
    > I have the following two methods in an asp/jscript page - my problem is
    that
    > without the update statement there is no error, but with the update
    > statement I get the following error:
    >
    > Error Type:
    > Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
    > [Microsoft][ODBC Microsoft Access Driver] Syntax error in UPDATE
    statement.
    > /polyprint/dataEntry.asp, line 158
    >
    > I fail to understand why there is a syntax error - I am pretty sure all of
    > the parameters to the Open method are ok..
    >
    > Any advice would be most welcome!
    >
    > Rob
    > :)
    >
    > function modifyNewsletter()
    > {
    > var _newsletter = getParameter ("edition");
    > var _language = getParameter ("language");
    >
    > var sql = "SELECT * " +
    > "FROM newsletterText " +
    > "WHERE (((newsletterText.pageName)='" + _newsletter + "') "
    +
    > "AND ((newsletterText.language)='" + _language + "')) " +
    > "order by newsletterText.paragraph asc";
    >
    > var newsletterText = getRecordSetForModifyingRecords (sql);
    >
    > while (!newsletterText.EOF)
    > {
    > Response.Write (newsletterText ("text") + " --- " +
    > newsletterText ("style") + "<br>");
    >
    > newsletterText ("text") = "changed...";
    >
    > // problem statement
    > newsletterText.Update;
    >
    > Response.Write (newsletterText ("text") + " --- " +
    > newsletterText ("style") + "<br>");
    >
    >
    > newsletterText.MoveNext();
    > } // end while
    >
    >
    > // Gets a recordset for modifying records.
    > // Uses the adLockOptimistic lock and accepts an sql statement.
    > function getRecordSetForModifyingRecords (sql)
    > {
    > var rs = Server.CreateObject ("ADODB.Recordset");
    > rs.Open (sql, // Source
    > polyprintConnection, // ActiveConnection
    > adOpenForwardOnly, // CursorType
    > adLockOptimistic); // LockType
    > return rs;
    > } // end getRecordSetForModifyingRecords function
    >
    >

    Ray at Guest

  5. #4

    Default Re: Syntax error in UPDATE statement- asp/jscript

    Looks like you're opening the recordset as ForwardOnly - which is obviously
    not updateable !


    "Robert Mark Bram" <relaxedrob@removethis.optushome.com.au> wrote in message
    news:3f9518d0$0$9554$afc38c87@news.optusnet.com.au ...
    > Hi All!
    >
    > I have the following two methods in an asp/jscript page - my problem is
    that
    > without the update statement there is no error, but with the update
    > statement I get the following error:
    >
    > Error Type:
    > Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
    > [Microsoft][ODBC Microsoft Access Driver] Syntax error in UPDATE
    statement.
    > /polyprint/dataEntry.asp, line 158
    >
    > I fail to understand why there is a syntax error - I am pretty sure all of
    > the parameters to the Open method are ok..
    >
    > Any advice would be most welcome!
    >
    > Rob
    > :)
    >
    > function modifyNewsletter()
    > {
    > var _newsletter = getParameter ("edition");
    > var _language = getParameter ("language");
    >
    > var sql = "SELECT * " +
    > "FROM newsletterText " +
    > "WHERE (((newsletterText.pageName)='" + _newsletter + "') "
    +
    > "AND ((newsletterText.language)='" + _language + "')) " +
    > "order by newsletterText.paragraph asc";
    >
    > var newsletterText = getRecordSetForModifyingRecords (sql);
    >
    > while (!newsletterText.EOF)
    > {
    > Response.Write (newsletterText ("text") + " --- " +
    > newsletterText ("style") + "<br>");
    >
    > newsletterText ("text") = "changed...";
    >
    > // problem statement
    > newsletterText.Update;
    >
    > Response.Write (newsletterText ("text") + " --- " +
    > newsletterText ("style") + "<br>");
    >
    >
    > newsletterText.MoveNext();
    > } // end while
    >
    >
    > // Gets a recordset for modifying records.
    > // Uses the adLockOptimistic lock and accepts an sql statement.
    > function getRecordSetForModifyingRecords (sql)
    > {
    > var rs = Server.CreateObject ("ADODB.Recordset");
    > rs.Open (sql, // Source
    > polyprintConnection, // ActiveConnection
    > adOpenForwardOnly, // CursorType
    > adLockOptimistic); // LockType
    > return rs;
    > } // end getRecordSetForModifyingRecords function
    >
    >

    Mike Florio Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139