CFUPDATE Query Error **Help**

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default CFUPDATE Query Error **Help**

    Ok, I am at a serious loss and am getting a headache trying to figure out
    what exactly is wrong with this simple code. I have a form that pulls
    information from a database and allows users to update the information. The
    code for that page is:


    <CFQUERY NAME="editmessage" DATASOURCE="subscriptions">
    SELECT *
    FROM tbl_Messages
    WHERE messageID = #URL.messageID#
    </CFQUERY>

    <head>
    <title><CFOUTPUT>#editmessage.type# Editor</CFOUTPUT></title>

    <style type="text/css">
    <!--
    .style38 {font-size: 14px}
    .style39 {font-family: Arial, Helvetica, sans-serif}
    .style40 {font-size: 16px; }
    -->
    </style>
    <body bgcolor="FFFFFF" text="000000">
    <CFOUTPUT query="editmessage">
    <form name="form" method="post" action="updatemessage.cfm">
    <table width="900" border="0" align="center" cellpadding="5" cellspacing="0">
    <tr>
    <td>&nbsp;</td>
    <td>[<a href="menu.cfm">Back to menu</a>] [<a
    href="logout.cfm">Logout</a>] </td>
    </tr>
    <tr>
    <td width="25%"><div align="right" class="style40"><span
    class="style39">Type:</span></div></td>
    <td width="75%">
    <input name="Type" type="text" value="#Type#" size="50">
    <span class="style38"></span></td>
    </tr>
    <tr>
    <td width="25%"><div align="right" class="style40"><span
    class="style39">From:</span></div></td>
    <td width="75%"><span class="style38">
    <input name="From" type="text" value="#From#" size="50">
    </span></td>
    </tr>
    <tr>
    <td width="25%"><div align="right" class="style40"><span
    class="style39">Subject:</span></div></td>
    <td width="75%"><span class="style38">
    <input name="Subject" type="text" value="#Subject#" size="50">
    </span></td>
    </tr>
    <tr>
    <td width="25%" valign="top"><div align="right" class="style40"><span
    class="style39">Body:</span></div></td>
    <td width="75%"><span class="style38">
    <textarea name="Body" cols="90" rows="10">#Body#</textarea>
    </span></td>
    </tr>
    <tr>
    <td colspan="2"><div align="center">
    <input type="submit" value="Update">
    </div></td>
    </tr>
    </table>
    </form>
    </CFOUTPUT>
    </body>

    Then on the page it posts to, I have the simple code of:

    <CFUPDATE datasource="subscriptions" tablename="tbl_Messages">

    However, I keep getting an error stating there is a syntax error in my
    update query code and I'm clueless as to why. I have tried several different
    things, but to no help. Please let me know what I am doing wrong. Thank you in
    advance.


    bfinelsen Guest

  2. Similar Questions and Discussions

    1. [microsoft][odbc microsoft access driver] syntax error (missing operator) in query expression error
      I have a query I want to run using DBQwiksite siftware, which produces the syntax error (missing operator) in query expression error when...
    2. Query of Query Error
      This is the error I get - Query Of Queries syntax error. Encountered ". Query Of Queries runtime error. The Cold Fusion server is running MX...
    3. CFUPDATE Issue
      Maybe its becuase iv been trying to figure this out for 6 hours but im stumped. and i know its a simple solution.. I have 2 pages (forms). im...
    4. <cfupdate> issue
      Input form.... <cfform name="mytst" method="post" action="hotels_edit_action.cfm"> <cfoutput><input name="HotelID" type="hidden"...
    5. Another Query of Query cast error
      Just in case somebody else is getting this error I thought I'd leave this here. I have a shopping cart that is stored in a session variable. When at...
  3. #2

    Default Re: CFUPDATE Query Error **Help**

    As a side note, I have also used the following code for the update with no
    luck:


    <CFQUERY NAME="UpdateMessage" DATASOURCE="subscriptions">
    UPDATE tbl_Messgae
    SET Type = '#Type#',
    From = '#From#',
    Subject = '#Subject#',
    Body = '#Body#'
    WHERE messageID = #messageID#
    </CFQUERY>

    bfinelsen Guest

  4. #3

    Default Re: CFUPDATE Query Error **Help**

    I don't know if it was just a typo in your post or not, but you misspelled tbl_Messages as tbl_Messgae in your UPDATE.

    Phil
    paross1 Guest

  5. #4

    Default Re: CFUPDATE Query Error **Help**

    Phil,

    Yes, I did notice that typo and I did correct that on my code as well, but still no luck :(
    bfinelsen Guest

  6. #5

    Default Re: CFUPDATE Query Error **Help**

    What is the actual error that you are getting with your UPDATE (cfquery)
    option? (I never use CFUPDATE because it has been notoriously problematic for
    lots of folks.) The ususal suspects are datat type mismatches, such as
    messageID actually being a character type and no quotes around #messageID#, etc.

    Phil

    paross1 Guest

  7. #6

    Default Re: CFUPDATE Query Error **Help**

    I am actually using this code now, as I have seen other issues in the forums
    with CFUPDATE:


    <CFQUERY NAME="UpdateMessage" DATASOURCE="subscriptions">
    UPDATE tbl_Messages
    SET From = '#Form.mesFrom#',
    Subject = '#Form.mesSubject#',
    Body = '#Form.mesBody#'
    WHERE Type = '#Form.mesType#'
    </CFQUERY>

    However, it is still returning an error and all it states in the CF log
    files is:


    Error Executing Database Query.[Macromedia][SequeLink JDBC Driver][ODBC
    Socket][Microsoft][ODBC Microsoft Access Driver] Syntax error in UPDATE
    statement. The specific sequence of files included or processed is:
    C:\websites\docs\subscriptions\updatemessage.cfm

    I tried turning debugging on to specify exactly what is wrong, but I'm not
    getting anything :(.....I did rename the field names becuase I was unsure if
    they were creating the problem, but again...no help


    bfinelsen Guest

  8. #7

    Default Re: CFUPDATE Query Error **Help**

    Also...to help the field name types in access are as follows:

    messageID = AutoNumber
    Type = Text
    From = Text
    Subject = Text
    Body = Memo
    bfinelsen Guest

  9. #8

    Default Re: CFUPDATE Query Error **Help**

    You have a field name in your table that I'm sure is causing your problem, as
    From is a reserved word. Try using brackets [ ] aroudn the offending word, and
    any such others in the future.

    <CFQUERY NAME="UpdateMessage" DATASOURCE="subscriptions">
    UPDATE tbl_Messages
    SET [From] = '#Form.mesFrom#',
    Subject = '#Form.mesSubject#',
    Body = '#Form.mesBody#'
    WHERE Type = '#Form.mesType#'
    </CFQUERY>

    Phil


    paross1 Guest

  10. #9

    Default Re: CFUPDATE Query Error **Help**

    Phil,

    I did rename the columns and changed the code, but didn't catch all of the
    code originally, so when I went back and corrected that, it works. Ultimately,
    I believe you are correct, that From was creating the problem, so I appreciate
    your help :)

    Ben

    bfinelsen Guest

  11. #10

    Default Re: CFUPDATE Query Error **Help**

    BTW, is there a place that lists all the current reserved words so that I can avoid this type of issue in the future?
    bfinelsen Guest

  12. #11

    Default Re: CFUPDATE Query Error **Help**

    Quick Google........

    [url]http://support.microsoft.com/default.aspx?scid=kb;%5BLN%5D;Q286335[/url]
    [url]http://www.databasedev.co.uk/ms-access-reserved-words.html[/url]
    [url]http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=tn_18050[/url]

    Phil

    paross1 Guest

  13. #12

    Default Re: CFUPDATE Query Error **Help**

    Awesome, again thank you so much for your help. You are a valuable asset to these forums :)
    bfinelsen 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