• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1520
  • Last Modified:

convert from string to boolean

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
lulu50
Asked:
lulu50
1 Solution
 
_Choggo_Commented:
try bool.Parse(string)
0
 
_Choggo_Commented:
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
 
Anurag ThakurTechnical ManagerCommented:
With Command.Parameters
       .Add("Search", SqlDbType.Bit).Value = Convert.ToBoolean(RDPrivacy.SelectedItem.Value)
End With
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
sm394Commented:
this can be an option
.Add("Search", SqlDbType.Bit).Value =iif( RDPrivacy.SelectedItem.Value.Equals("1"),true,false)
0
 
lulu50Author Commented:
Thank you Excellent
0
 
VibhugCommented:
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

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now