【发布时间】:2015-03-02 03:02:42
【问题描述】:
我正在使用此查询向日期时间字段插入空值:
echCommand="INSERT INTO GPEC_TBL_ECHEANCE(echeance, echeance_debut, echeance_fin, objectif_id)
VALUES (null, " + System.DBNull.Value + "," + System.DBNull.Value + "," + newObjectifId + ")";
var echCommand = new SqlCommand(insertEchQuery, con);
但是在显示 GridView 时,我仍然得到日期 1900-01-01 !
我应该添加或修改什么以在我的 Gridview 中有一个空白字段而不是这个丑陋的日期?
【问题讨论】:
-
附注 - 如果不是绝对必要,请勿使用非参数化查询!
-
谢谢,我在原始代码中使用了
echCommand.Parameters.AddWithValue("@retrievedDebutEcheance", System.DBNull.Value);,但结果仍然相同:( -
您的问题可能不在该查询中。查看您的数据库:它真的为空,还是数据库设置了默认值?查看结果集:它是 null,还是默认值?并查看 NullValue、NullFormat 或网格视图的任何名称。
标签: asp.net datetime gridview null