Pass null value to stored procedure

Below example will show you how to pass null value to stored procedure parameter from c#

Passing null value for integer type parameter

//If user id is grater than 0 then assign user id other wise pass null value if (intUserID > 0) SqlCmd.Parameters.AddWithValue("@UserID", intUserID); else SqlCmd.Parameters.AddWithValue("@UserID", DBNull.Value);

Common Syntax

SqlCmd.Parameters.AddWithValue("@ParameterName", DBNull.Value);