Skip navigation
Currently Being Moderated

pass check box value to stored procedure

Sep 10, 2013 8:30 AM

I have a check box on the form and want to pass it check or not to my cfstoredproc.

I tried to use followign code I got invalid data error message, I tried to use cf_sql_bit, cf_sql_int, but I always get error message,

 

My stored procedure expect bit data type, but I can change what ever the check box value is for database server stored procedure.

 

Your help and information is great appreciated,

 

Regards,

 

Iccsi,

 

 

<cfstoredproc procedure="MySP">

<cfprocparam value="form.MyCheckBox" cfsqltype="cf_sql_tinyint">

<cfprocresult name="SP1" resultset="1">

</cfstoredproc>

 

 

<cfinput type="checkbox" name="MyCheckBox" value="MyCheckBox" id="MyCheckBox">

 
Replies
  • Currently Being Moderated
    Sep 10, 2013 9:02 AM   in reply to iccsi

    iccsi,

     

    I think the problem you are experiencing is related to how ColdFusion stores boolean values.  They are stored as true booleans, not as integer values.  So you can't pass them directly to the database as a cf_sql_bit or cf_sql_int value.  I usually use a User Defined Function (UDF) to convert boolean values to bit values so they can be used in database interactions.  Here is a similar UDF from CFLib.org.

     

    HTH,

    -Carl V.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points