Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

InsertParameters.Add Problem with Checkbox -- Visual Basic

Posted on 2008-10-21
3
Medium Priority
?
906 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

715 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