Copy link to clipboard
Copied
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="">
Thanks. I'm new to ColdFusion and this is someone else's code. I appreciate the help.
Copy link to clipboard
Copied
Comma after your SET statement. Almost as if it's "near the keyword 'WHERE'" ![]()
AND WHERE ARE YOUR QUERYPARAMS?!
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Thanks. I'm new to ColdFusion and this is someone else's code. I appreciate the help.
Copy link to clipboard
Copied
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
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more