Getting a Bit from SqlServer into c#
c#, sql
Solution
If you're certain that the column values will never be `NULL` then the following will do the trick:
bool active = rdr.GetBoolean(rdr.GetOrdinal("Active"));
If it's possible that `NULL` values might be returned:
int oActive = rdr.GetOrdinal("Active");
bool? active = rdr.IsDBNull(oActive) ? (bool?)null : rdr.GetBoolean(oActive);
Problem
I need to get a Bit from a sql server into c#. I tried differnt solutions like: ``` bool active = rdr.GetSqlBinary(5); Int16 active = rdr.GetSqlBinary(5); ``` But can't find any way to get the Bit. Can someone give an example?