在CS代码中传入值操作:

                    Nullable<DateTime> instoragedate = null;

                    if (!string.IsNullOrEmpty(instorage))
                        instoragedate = Convert.ToDateTime(instorage);

在SQL查询时操作:  case when convert( varchar(12) ,InStorageDate,111)='1900/01/01' then '' else convert( varchar(12) ,InStorageDate,111) end  as InStorageDate

 

总结:在前台传值的时候有两种选择:传入   null ,或者传入  dbnull.value

        其中如果传入Null值 则在数据库中自动为1900/01/01等,那么取值的时候要做操作,优点是CS代码的时候方便操作

        传入DBNULL.VALUE,则在SQL中保存为空,优点是数据库SQL查询的时候方便操作

 

 

相关文章:

  • 2021-06-15
  • 2021-08-09
  • 2021-09-03
  • 2021-12-26
  • 2021-09-28
  • 2022-12-23
  • 2021-10-11
  • 2022-12-23
猜你喜欢
  • 2021-06-01
  • 2022-12-23
  • 2021-12-13
  • 2022-03-04
  • 2022-02-09
  • 2022-01-06
  • 2021-04-22
相关资源
相似解决方案