Rookie Question

B

Big E

I'm using ASP.Net and SQL Server.
In the database I have a bit field.
On the webform I have a checkbox.
When I do a insert or update I want the checkbox to equal the bit field.
When I do a checkbox1.Text it equals nothing "".
When I do a checkbox.checked it equals True or False.
How can I have it equal 0 or 1

Thanks.

Erik
 
G

GSK

If using a stored procedure, simply send the value (boolean) of
checkbox1.checked. MSSQL will convert it to a bit. This is if you are
updating or inserting data from a form.

If you are creating your SQL within the code-behind (not recommended), then
you may have to use a simple if statement to convert your checkbox.checked
to a '1' or '0'.

If you are populating your form from contents in the database, try setting
checkbox.checked to Boolean.Parse(<data value>). There are other methods for
converting to a boolean as well I believe.

- gsk.
 

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

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top