开发者

Bool type in SQL Server 2008

开发者 https://www.devze.com 2023-02-28 14:07 出处:网络
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 h

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?

开发者_如何学Go

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


Second one. C# is very strongly typed.

lblUserActive.Text = ud.UserActive != 0 ? "Activated" : "Not Activated";
0

精彩评论

暂无评论...
验证码 换一张
取 消