bool
/
Boolean
in .NET and
bit
in SQL are the same type. There is no conversion required.
When you're reading a
bit
field from SQL, it's already a
bool
; either cast the value to
bool
, or use the
Field<bool>
extension method:
bool theValue = (bool)reader["YourBitColumn"];
bool theValue = reader.Field<bool>("YourBitColumn");
When you're passing a
bool
as a
bit
parameter to a query, just pass it in:
bool theValue = true;
command.Parameters.AddWithValue("@YourBitParameter", theValue);