I have a C# property which is of data type bool
and when it gets set, it becomes a True
or False
.
However I need for it to match up with a SQL Server table column of type bit
so that it is saved as a 1 or 0.
SQL Server column:
StormOut bit
C# property
public bool StormOut { get; set; }
C# SQL statement:
string querystring = "UPDATE tblSignOnOff SET StormOut = " + storm.StormOut + " WHERE id = 1902";
Otherwise currently the SQL statement in C# is
UPDATE tblSignOnOff
SET StormOut = True
WHERE id = 1902
Which results in an error:
Invalid column name 'True'.
Parameters.AddWithValue
to make a parameterized query which probably might help yop – Banquette