c# - 当 allow null 为真时,为什么默认值不插入列中?

标签 c# sql-server-2008 dataset

我有一个表地址,其中一个名为“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.

Reference

关于c# - 当 allow null 为真时,为什么默认值不插入列中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14375904/

相关文章:

R mtcars数据集, "vs"变量的含义?

hadoop - 如何在 oozie 协调器中使用一天的旧数据集

neo4j drwho 数据集升级到 3.0 不起作用

c# - C#中最快的生产者消费者方法是什么

c# - SQL Server 连接计数问题

c# - 公共(public)变量调用不正确的结果

c# - 使用自动完成和 Ajax 进行搜索

日期时间类型的 SQL LIKE 语句

sql - 在多个变量上使用 RANK 的快速帮助

sql-server-2008 - 从另一个存储过程获取结果摘要