亚音速3 / ASP.net MVC尝试在datetime列保存一个空值 [英] Subsonic 3/ASP.net mvc trying to save a null value in a datetime column

查看:213
本文介绍了亚音速3 / ASP.net MVC尝试在datetime列保存一个空值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有保存系统的用户与他们的最后一次登录的日期和时间在这上面的表。该系统的管理员用户需要能够添加用户,但是当我添加新的用户记录,除非我把有效的datetime在最后一次登录的日期字段发生了验证错误。

I have a table that holds system users with their last login date and time in it. The admin users of the system need to be able to add users, but when I add the new user record a validation error occurs unless I put a valid datetime in the last login date field.

我已经试过手动更改领域的DBNull,空,等保存之前,但它说,这些值不能转换为datetime。该列允许在db空值。

I've tried manually changing the field to dbnull, null, etc prior to the save but it says those values cannot be converted to datetime. The column does allow nulls in the db.

有什么建议?

推荐答案

如果您设置LastLogin是日期时间?那么你可以传递空到数据库而不衰。

If you set LastLogin to be DateTime? then you can pass null to the DB without failure.

这篇关于亚音速3 / ASP.net MVC尝试在datetime列保存一个空值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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