码迷,mamicode.com
首页 > 数据库 > 详细

Cannot set Column 'EffectiveDate' to be null. Please use DBNull instead.

时间:2020-11-12 13:57:50      阅读:12      评论:0      收藏:0      [点我收藏+]

标签:not   datarow   project   question   ast   data   instead   www   tps   

dt.Columns.Add("EffectiveDate", typeof(DateTime));

   DateTime?   effectivedate=null;


  if (lastRow["Effective_x0020_Date"] != DBNull.Value)
  {

     effectivedate = Convert.ToDateTime(lastRow["Effective_x0020_Date"]);
  }


DataRow dr = dt.NewRow();
     dr["EffectiveDate"] = effectivedate;
dt.Rows.Add(dr);

  

Fix

dr["EffectiveDate"] = effectivedate ?? (object)DBNull.Value;

 

 

来源:https://www.codeproject.com/Questions/867120/Cannot-set-Column-EffectiveDate-to-be-null-Please

Cannot set Column 'EffectiveDate' to be null. Please use DBNull instead.

标签:not   datarow   project   question   ast   data   instead   www   tps   

原文地址:https://www.cnblogs.com/shy1766IT/p/13809711.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!