Solved

convert from string to boolean

Posted on 2008-10-25
6
1,512 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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

747 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

12 Experts available now in Live!

Get 1:1 Help Now