Solved

convert from string to boolean

Posted on 2008-10-25
6
1,515 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

685 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