Reputation: 1853
I have a row with nullable
columns in my table in SQL Server. I tried to store values like this.
if (chkQCE3AS1.Checked)
cmd.Parameters.AddWithValue("QCEA1S1", selectedID);
else
cmd.Parameters.AddWithValue("QCEA1S1", "");
But that would store a space in the column. What would be another way to store a null
value? Or is it even a good idea?
Upvotes: 1
Views: 772
Reputation: 176956
Make use of DBNull that will do your task.
if (chkQCE3AS1.Checked)
cmd.Parameters.AddWithValue("QCEA1S1", selectedID);
else
cmd.Parameters.AddWithValue("QCEA1S1", DBNull.Value);
Upvotes: 9