Go Back   CodingForums.com > :: Server side development > Other server side languages/ issues > ColdFusion

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-04-2010, 02:43 PM   PM User | #1
JohnShell
New Coder

 
Join Date: Dec 2009
Posts: 42
Thanks: 13
Thanked 0 Times in 0 Posts
JohnShell is on a distinguished road
SQL Insert with cfif isdefined

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
Code:
<cfif isdefined('form.startdate')>
	<cfif #form.startdate# is not ""> '#form.startdate#',</cfif>
           <cfelse >null, 
	   </cfif>
The input form code is
Code:
<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 is offline   Reply With Quote
Old 11-04-2010, 04:26 PM   PM User | #2
JohnShell
New Coder

 
Join Date: Dec 2009
Posts: 42
Thanks: 13
Thanked 0 Times in 0 Posts
JohnShell is on a distinguished road
Hey,

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

Code is now
Code:
<cfif isdefined('form.startdate') and #form.startdate# is not ""> '#form.startdate#',
     	<cfelse > null,
	   </cfif>
JohnShell is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:23 PM.


Advertisement
Log in to turn off these ads.