Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Dec 2009
    Posts
    42
    Thanks
    13
    Thanked 0 Times in 0 Posts

    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

  • #2
    New Coder
    Join Date
    Dec 2009
    Posts
    42
    Thanks
    13
    Thanked 0 Times in 0 Posts
    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>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •