InsertParameters.Add Problem with Checkbox -- Visual Basic

I get this error " String was not recognized as a valid Boolean. "

NewsletterOptOutCheckBox is a checkbox within my webform.  I am trying to insert it into a database table along with like 10 other values.  I have tested it with all the other values which are mostly textboxes and it works great.

How do I pass a checkbox from the visual basic code into the ms sql db column "Opt_Out" of type BIT?
DataSource.InsertParameters.Add("Opt_Out", TypeCode.Boolean, NewsletterOptOutCheckBox.ToString())

Open in new window

LVL 1
HarleySkaterAsked:
Who is Participating?
 
dctuckConnect With a Mentor Commented:
Try:
DataSource.InsertParameters.Add("Opt_Out", TypeCode.Boolean, NewsletterOptOutCheckBox.Checked)
 

Open in new window

0
 
HarleySkaterAuthor Commented:
Close!
DataSource.InsertParameters.Add("Opt_Out", TypeCode.Boolean, NewsletterOptOutCheckBox.Checked.ToString())

Open in new window

0
 
dctuckCommented:
D'oh! I thought .ToString(), but forgot to put it....
Glad it worked anyway
0
All Courses

From novice to tech pro — start learning today.