Subsonic 3/ASP.net mvc trying to save a null value in a datetime column

情到浓时终转凉″ 提交于 2019-12-24 18:58:13

问题


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.

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.

Any suggestions?


回答1:


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




回答2:


Can you alter the table structure? If so, you can define a default value like "1970.01.01", for example.



来源:https://stackoverflow.com/questions/975457/subsonic-3-asp-net-mvc-trying-to-save-a-null-value-in-a-datetime-column

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!