Solved

InsertParameters.Add Problem with Checkbox -- Visual Basic

Posted on 2008-10-21
3
883 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 500 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

758 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now