SQL参数为空 [英] SQL Parameter IsNullable
问题描述
通过SqlParameter类(对于C#),我可以在存储过程中看到参数.
Through the SqlParameter class (for C#) I can see parameters in a stored procedure.
您怎么知道参数是否是必需的?我尝试使用IsNullable,但始终为假.
How do you know if a parameter is mandatory or not? I tried using IsNullable but it's always false.
也许我正在编写错误的存储过程,或者IsNullable只是用于设置?
Maybe I'm writing a wrong stored procedure, or is IsNullable meant just to set?
谢谢
推荐答案
可选"仅表示存储过程参数为默认值.
否则,所有参数可以为NULL:没有定义约束可以停止此操作.
"Optional" simply means there is a default for stored procedure parameters.
Otherwise, all parameters can be NULL: there is no definition constraint to stop this.
按照此答案,您必须解析存储的proc T-SQL以查看默认值是否有解决方案给定存储过程的参数的默认值?
You'd have to parse the stored proc T-SQL to see the default, as per this answer Is there a solution for getting the default value of the parameters of a given stored procedure?
如果您可以解析存储的proc定义,那么您将开始失去封装优势
And if you can parse the stored proc definition, then you start to lose the encapsulation benefits
这篇关于SQL参数为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!