I have a probleme with a sql query :
I would like do something like :
SELECT * FROM myTable WHERE [myBoolField] IS NULL
if i run this query, i have my results,
but i would like use parameters, so i add :
SELECT * FROM myTable WHERE [myBitField] IS @myBitField
with
New SqlParameter("@myBitField", dbnull.value)
i have an error at the @myBoolField
if i pass a value like true or false, that's work ( with " = @myBitField")
Can someone help me ?
Thanks
You can only test for NULL using IS NULL
. You cannot use parameters and there wouldn't really be any point.
DBNull.Value
can be used when inserting or comparing values in code, but not on WHERE
conditions since NULL is not equal to even another NULL.