View Full Version : SQL Insert with cfif isdefined

11-04-2010, 03:43 PM

I am new to this language and am experiencing a problem. I have a simple form for user input. I have a javascript date picker for two input boxes. If a user selects a date it is posted to the SQL Server 2008 db. If a user leaves it blank I get an error. My action page code for that item is

<cfif isdefined('form.startdate')>
<cfif #form.startdate# is not ""> '#form.startdate#',</cfif>
<cfelse >null,

The input form code is

<td><input style="width: 70px" type="text" id="startdate" name="startdate" /></td>

The error is

[Macromedia][SQLServer JDBC Driver][SQLServer]There are more columns in the INSERT statement than values specified in the VALUES clause. The number of values in the VALUES clause must match the number of columns specified in the INSERT statement.

Any suggestions? I am at wit's end on this one.


11-04-2010, 05:26 PM

Thanks for looking. I changed the code and all is well. Ah, the learning experience.

Code is now

<cfif isdefined('form.startdate') and #form.startdate# is not ""> '#form.startdate#',
<cfelse > null,