【问题标题】:passing null to DBtype.binary将 null 传递给 DBtype.binary
【发布时间】:2010-11-21 14:21:44
【问题描述】:

我正在使用 sqlparameter 通过过程将值插入到表中 我在图像类型的过程中有一个参数 在 c# 中,我将参数类型设置为 DbType.Binary 现在我想将 Null 值传递给参数,如果我使用 DBNull.value,我得到不兼容的数据类型错误

【问题讨论】:

  • 如果将其设置为 CLR null 会发生什么?

标签: c# sql-server ado.net


【解决方案1】:

尝试这样 int sp set parametar default value null like this @parametar Binary = NULL 然后在代码中测试该值是否为null,如果为null,则不要将参数传递给sp,它将采用默认值null。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-03-20
    • 2020-02-02
    • 2021-04-27
    • 2021-01-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-02
    相关资源
    最近更新 更多