views:

421

answers:

2

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?

A: 

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

Gordon
Because this is a new user setup view, they have not logged in yet. That is why we need last login to be blank.
chad
A: 

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

Rob Conery
Thanks Rob, that did it. And thank you for subsonic. One more quick question. I had to make that change in the classes generated by your T4 template. Would you recommend I change your template for nullable datetime columns, or is there a way to use a partial class to override the column property of that table's subsonic 3 class? Thanks again!
chad
I have asked the second question in this post as well:http://stackoverflow.com/questions/987325/subsonic-3-asp-net-mvc-issue-trying-to-override-class-column-properties
chad
I've made that change in the trunk and it will be included with the release. And you're welcome!
Rob Conery