C# ASP.Net Parameters.AddWithValue rejecting null value for parameter

前端 未结 7 1743
臣服心动
臣服心动 2021-01-18 04:22

I am populating tables using a stored procedure. The table allows a \'null\' for the middle initial of the name, but I\'m getting the following error message:

7条回答
  •  孤城傲影
    2021-01-18 05:01

    You need to declare on everything - even if it's null.

    Use DBNull.Value for MiddleInitial.

    cmd.Parameters.AddWithValue("@MiddleInitial",DBNull.Value);
    

提交回复
热议问题