0

我在使用 AddInParameter 方法插入空参数时遇到问题。

cmd.AddInParameter(someString, someValueWhichCanBeNULL)

一旦第二个参数为空,它就会失败。我也试过 DBNull.Value,也失败了。想法?

消息是:AddInParameter @MyParam 具有空值不支持的属性类型:DBNull

谢谢!

4

1 回答 1

0

使用AddInParameter需要三个参数的重载;你要这个:

cmd.AddInParameter(someString, DbType.String, someValueWhichCanBeNULL);

(它不能单独从 DBNull.Value 确定参数的类型)

希望有帮助!

于 2010-07-21T09:21:26.447 回答