Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

InsertParameters.Add Problem with Checkbox -- Visual Basic

Posted on 2008-10-21
3
Medium Priority
?
914 Views
Last Modified: 2008-10-21
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

0
Comment
Question by:HarleySkater
  • 2
3 Comments
 
LVL 7

Accepted Solution

by:
dctuck earned 2000 total points
ID: 22768116
Try:
DataSource.InsertParameters.Add("Opt_Out", TypeCode.Boolean, NewsletterOptOutCheckBox.Checked)
 

Open in new window

0
 
LVL 1

Author Comment

by:HarleySkater
ID: 22768173
Close!
DataSource.InsertParameters.Add("Opt_Out", TypeCode.Boolean, NewsletterOptOutCheckBox.Checked.ToString())

Open in new window

0
 
LVL 7

Expert Comment

by:dctuck
ID: 22768705
D'oh! I thought .ToString(), but forgot to put it....
Glad it worked anyway
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Integration Management Part 2
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

876 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question