Using DBNull.Value with SqlParameter without knowing sqlDbType?

前端 未结 5 1310
有刺的猬
有刺的猬 2021-01-05 19:42

I\'m using a SqlParameter to pass in null values to a table for various columns that are nullable. The problem is that SqlParameter looks like it defaults to nv

5条回答
  •  鱼传尺愫
    2021-01-05 20:13

    Old post but might be helpful someone else.

    Convert.DBNull
    

    Like this

    command.Parameters.AddWithValue("@param", Convert.DBNull);
    

提交回复
热议问题