-1
How can I make an if by checking whether the data of a column in the Database table is True or False?
For example:
using (SqlCommand cmd = new SqlCommand($"SELECT LoginID,Award FROM Sys_Usuarios_Award WHERE LoginID={login.LoginId} and Award='true ou false'", connection))
What I have in mind:
if (Award == True){
Console.WriteLine("True");
}else{
Console.WriteLine("False");
}
Award is the column I picked up at Sqlcommand. Summing up wanted to make an if with the bit data of a column but don’t know how to do.
If the column is
bit
, true=1 and false=0, so something likeand (Award=1 or Award=0)
but I didn’t understand the purpose of this OR, since the field can only assume these values... it is nullable? Can explain better?– Ricardo Pontual
It’s just for example, it can be both true and false, I just want to make an if, if it’s True, Console.Writeline("True"); if it’s False Console.Writeline("False")
– user92401
I thought you were talking about how to do
query
, but the code depends on how your data comes,DataReader
,DataTable
, etc.– Ricardo Pontual