Skip to main content
Inspiring
October 25, 2011
Answered

Need help with incorrect syntax error during a record update

  • October 25, 2011
  • 3 replies
  • 3706 views

I'm getting the error below but I cannot figure out what I'm doing wrong.

Error Executing Database Query.

[Macromedia][SQLServer JDBC Driver][SQLServer]Incorrect syntax near the keyword 'WHERE'.

The error occurred in C:\ColdFusion9\wwwroot\Intranet\DM\Admin\Maintenance-BulbBaseType.cfm: line 23

21 :             UPDATE [Bulb Base Type Table]

22 :             SET [BulbBaseTypeDesc] = '#TxtBulbBaseTypeDesc#',

23 :             WHERE ([BulbBaseTypeID] = #TxtID#)

24 :         </cfquery>

25 :         <cfset TxtID = 0>

I have set my cfparam as:

<cfparam name="Submit" default="">

<cfparam name="TxtID" default=0>

<cfparam name="TxtBulbBaseTypeDesc" default="">

    This topic has been closed for replies.
    Correct answer btvbillb

    Thanks. I'm new to ColdFusion and this is someone else's code. I appreciate the help.

    3 replies

    btvbillbAuthorCorrect answer
    Inspiring
    October 25, 2011

    Thanks. I'm new to ColdFusion and this is someone else's code. I appreciate the help.

    Inspiring
    October 25, 2011

    In addition to the other answers, I find that leading commas are easier to work with than trailing commas.  Something like this:

    update YourTable

    set field1 = value1

    , field2 = value2

    , field3 = value3

    etc

    Inspiring
    October 25, 2011

    A good rule of thumb when encountering this sort of error message is to examine the preceding line of code.

    If you do that with your query, you should spot the trailing comma at the end of the line.

    Also: read up on CFQUERYPARAM.  Don't hard-code dynamic values in your SQL string.

    --

    Adam

    Owainnorth
    Inspiring
    October 25, 2011

    Comma after your SET statement. Almost as if it's "near the keyword 'WHERE'"

    AND WHERE ARE YOUR QUERYPARAMS?!