如何在SQL中将null值设置为datetime字段 [英] How to set the null values to the datetime field in SQL

查看:388
本文介绍了如何在SQL中将null值设置为datetime字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在数据库中使用两个datetime字段.对于某些情况,我想将一个空值保存到该列中.以前,我是在编辑后存储日期和时间的,我想将空值保存到该字段中.我试过把"null","string.Empty","Sqltype.Datetime.null","dbnull"放进去,但是它抛出一个对象引用错误.谁能帮我解决这个问题

在此先感谢

Hi,

I am using two datetime field in my database. For some condition I want to save a null values into that column. Previously I have stored the dateandtime after editing I want to save the null values into that field. I have tried putting "null","string.Empty","Sqltype.Datetime.null","dbnull" but it throws an object reference error. Can anyone help me to solve this problem

Thanks in advance

推荐答案

using System.Data.SqlTypes;


  System.Data.SqlTypes.SqlDateTime getDate;
  getDate =  SqlDateTime.Null;


这篇关于如何在SQL中将null值设置为datetime字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆