I have a column named source of type bit in my database. but I want to get set its value in my program. how can I do that? I know it was a simple doubt but I was little bit confused. Do I have to use byte as type while setting this or not?
Use bool for representation bit from database:
public bool MyBitDbProperty {get;set;}
If you use SqlDataReader than use reader.GetBoolean(position) for bit type.
If you use any rdbms(like linq to sql), bit will mapped to bool by default.
The bit database type will contain the values 0 and 1, and normally (you've not stated RDMS) corresponds nicely with the bool or Boolean types in c#.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With