我有一个表地址,其中一个名为“faxno”的列允许 null 并且默认值为 0。当我们使用数据集以编程方式插入记录时,我们得到的 faxno 值为“Null”而不是“0” .
我不明白为什么会这样?
是否可以插入默认值而不是 Null?
最佳答案
在您的插入语句中,排除 faxno
列。
In the case of a nullable column, the default value will be used when an insert occurs and the column name is excluded from the statement. To insert a null value, the column must be included in the list and the value of null must be inserted explicitly.
关于c# - 当 allow null 为真时,为什么默认值不插入列中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14375904/