chad
chad

Reputation: 5

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

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?

Upvotes: 0

Views: 883

Answers (2)

user1151
user1151

Reputation:

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

Upvotes: 2

Gordon
Gordon

Reputation: 147

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

Upvotes: 0

Related Questions