Solved

InsertParameters.Add Problem with Checkbox -- Visual Basic

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

828 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