Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bool type in SQL Server 2008

In my DB I have a row UserActive. It is supposed to be bool. SQL Server does not support bool data type. The similar or close to it is bit 0/1. Ok if I'll make this column bit typed, then how I can handle with it in my C# code? Should I use bool type in my code?

Example

if (ud.UserActive != true)
{
   lblUserActive.Text = "Disactivated";
}
else
{
   lblUserActive.Text = "Activated";
}

or

if (ud.UserActive == 1)
{
   lblUserActive.Text = "Activated";
}
else
{
   lblUserActive.Text = "Disactivated";
}

Thank you for reply

like image 205
NCFUSN Avatar asked Nov 14 '22 00:11

NCFUSN


1 Answers

Second one. C# is very strongly typed.

lblUserActive.Text = ud.UserActive != 0 ? "Activated" : "Not Activated";
like image 133
Christo Avatar answered Dec 24 '22 23:12

Christo