Data Type for a CheckBox

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am using a SQL server database and am using a Check Box on my .aspx screen.
What data type should I use when I design my table? I tried bit but When I
ran the program and Checked one of the check boxes I got a msg: True is not a
valid value for int16. I changed the data type to small int, re-ran the
program, checked the box and got: Entered value cannot be converted to int16.
 
you can check the condition/state of checkbox and then send value from your
side e.g. 1 for true and 0 or false.
 
Hi,

You should use bit:

//Store in the DB
com.Parameters.Add("@internalDOTReq", SqlDbType.Bit).Value =
this.internaldotrequest?1:0;

//retrieve from DB
bool internaldotrequest = (bool)reader["internalDOTReq"];


cheers,
 
BigAl said:
I am using a SQL server database and am using a Check Box on my .aspx
screen.
What data type should I use when I design my table? I tried bit but When
I
ran the program and Checked one of the check boxes I got a msg: True is
not a
valid value for int16. I changed the data type to small int, re-ran the
program, checked the box and got: Entered value cannot be converted to
int16.

Hi BigAl,

it shuold work with datatype bit in SQL Server and Boolean in the DataSet!!
Hope that helps
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top