We have a table that has a column
Checked who has
Binary (1) as data type. Basically, it stores 0x00 or 0x01 to indicate if this line of data is checked.
I knew that it would be better to use
Bit as data type, but there are already a lot of other modules associated with this table, so let 's stay as is for the moment.
I've tried intuitive ways like
// _dr is the SqlDataReader Convert.ToBoolean (_dr["IsChecked"]) (bool) _dr["IsChecked"];
but he can not just convert like that, so I've tried some approaches that could work
bool.Parse (_dr["IsChecked"].ToString ()); Convert.ToBoolean ((byte) _dr["IsChecked"]) Convert.ToBoolean ((byte) _dr["IsChecked"]) Convert.ToBoolean ((int) _dr["IsChecked"])
But all of the above turns me back to convert
The specified distribution is not valid.
I check how my colleague read this field in his module and this seems to require an output parameter that has
Bit as a type of data to get the value out.
But there should be an easier way to do the same thing, right?
I just need to know how to convert correctly