Solved

convert from string to boolean

Posted on 2008-10-25
6
1,513 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
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…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

932 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

11 Experts available now in Live!

Get 1:1 Help Now