...

View Full Version : SQL Insert with cfif isdefined



JohnShell
11-04-2010, 02:43 PM
Hi,

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,
</cfif>


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.

Thanks,
John

JohnShell
11-04-2010, 04:26 PM
Hey,

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,
</cfif>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum