Solved

InsertParameters.Add Problem with Checkbox -- Visual Basic

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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

710 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