Question about Updating a record

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

  1. #1

    Default Question about Updating a record

    Ok, here's what we can assume:
    <cfset update = "ALIAS = 'Gruu'">
    <cfset id = '999'>

    Here's the simplified query:
    <cfquery name="angryquery" datasource="ds">
    UPDATE TableName
    SET #update#
    WHERE (key = '#id#')
    </cfquery>

    And here's what CF has to say about that:
    Error Occurred While Processing Request
    Error Executing Database Query.
    [Macromedia][SQLServer JDBC Driver][SQLServer]Line 2: Incorrect syntax near
    'Gruu'.


    Any ideas? The field 'alias' is capable of holding 'Gruu' as its value, and
    the field 'key' is a unique identifier. Any input is appreciated.

    Jeremy F Guest

  2. Similar Questions and Discussions

    1. Updating record remotely from a script?
      I have a MySQL database on my ISP's Linux server. Can anyone tell me if it would be possible to update a specific record remotely without any user...
    2. Problems when updating record
      I am having a problem with the following code with mySQL. I normally write with Access and do not get this problem, is there something that I am...
    3. Updating a NEW record
      ASP/Access Say a user creates a new record and needs to complete multiple forms, on multiple pages.... How do you submit the data to each page...
    4. Updating MySQL record
      Hi! I'm heaving a small problem updating a record containing an encrypted password. I'm using aes_encrypt. This is my suggestion for the query...
    5. Updating a single record on a form
      Hi Dennis, You need to look at the properties that begin with 'Allow....'. For example Allow Additions (allows/prevents adding new records). ...
  3. #2

    Default Re: Question about Updating a record

    I would say the problem is that the id is an integer and you have it inclosed
    in single quotes, should be

    <cfquery name="angryquery" datasource="ds">
    UPDATE TableName
    SET #update#
    WHERE (key = #id#)
    </cfquery>

    Ken

    The ScareCrow Guest

  4. #3

    Default Re: Question about Updating a record

    Fair enough answer, but not the problem. The query executes just fine if I do

    UPDATE TableName
    SET ALIAS = 'Gruu'
    WHERE (key = '#id#')

    But fails if I do:

    UPDATE TableName
    SET #update#
    WHERE (key = 999)

    Strange, eh?

    Jeremy F Guest

  5. #4

    Default Re: Question about Updating a record

    Does it fail if you do

    UPDATE TableName
    SET #update#
    WHERE (key = '999')

    Give this a try

    <cfset update = "[ALIAS] = 'Gruu'">

    Ken

    The ScareCrow Guest

  6. #5

    Default Re: Question about Updating a record

    I've found the solution. Thanks again for your help.

    PreserveSingleQuotes()

    Who knew...
    Jeremy F 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