As the title says, I'm trying to set an SqlParameter to null. Everytime my "id" = 0 I want the value to be sent as null. My guess apparently is wrong if you note the below code. With or without quotes the id = null; just doesn't work. Each time I get a message that @ID is expected by the SP and wasn't supplied.
Any Suggestions?
Any Suggestions?
Code:
[b]
SqlParameter[] parameters =
{
new SqlParameter("@ID", SqlDbType.Int, 4),
new SqlParameter("@ClientID", SqlDbType.Int, 4),
new SqlParameter("@PersonnelID", SqlDbType.Int, 4)
};
if (id != 0)
{
parameters[0].Value = id;
}
else
{
parameters[0].Value = null;
}
[/b]