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
Solved

convert from string to boolean

Posted on 2008-10-25
6
1,514 Views
Last Modified: 2010-05-05
Hi,
I have this error

Failed to convert parameter value from a String to a Boolean.

here is my code.

 With Command.Parameters
            .Add("Search", SqlDbType.Bit).Value = RDPrivacy.SelectedItem.Value
        End With

RDPrivacy is a radio button that has value of 0 or 1

thanks
0
Comment
Question by:lulu50
6 Comments
 
LVL 1

Expert Comment

by:_Choggo_
ID: 22803060
try bool.Parse(string)
0
 
LVL 1

Expert Comment

by:_Choggo_
ID: 22803064
or you can try, if it comes as "1" when it's true then simply comapre:



With Command.Parameters
            .Add("Search", SqlDbType.Bit).Value = RDPrivacy.SelectedItem.Value = "1"
        End With

Open in new window

0
 
LVL 26

Expert Comment

by:Anurag Thakur
ID: 22803237
With Command.Parameters
       .Add("Search", SqlDbType.Bit).Value = Convert.ToBoolean(RDPrivacy.SelectedItem.Value)
End With
0
Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

 
LVL 13

Accepted Solution

by:
sm394 earned 500 total points
ID: 22803575
this can be an option
.Add("Search", SqlDbType.Bit).Value =iif( RDPrivacy.SelectedItem.Value.Equals("1"),true,false)
0
 

Author Closing Comment

by:lulu50
ID: 31509939
Thank you Excellent
0
 

Expert Comment

by:Vibhug
ID: 32642272
I have a situation where I am generating dynamic conditions to check like

string condition="100 < 125"

how can I convert it to boolean as I have to check the condition and depending on the result I have to move ahead. How to do when I try

Convert.ToBoolean(condition).toString()
It gives error. Please let me know the solution.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

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 …
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

838 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