SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11
When inserting data with the NHibernate orm framework, the above error was reported:
SqlDateTime overflow / SqlDateTime overflow [Summary: Error - SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM War 12/31/9999 11:59:59 PM Reason When applying C# insert or update database, datetime word]
Error - SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM
Cause
When using C# insert or update database, the datetime field value is null by default insertion C# 0001-01-01 causes sql server datetime type overflow.
DateTime type range in C#
DateTime.MinValue = 1/1/0001 12:00:00 AM DateTime.MaxValue = 23:59:59.9999999, December 31, 9999, exactly one 100-nanosecond tick before 00:00:00, January 1, 10000 Datetime type range in Sql Server
between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM
After reading this article, I probably understand something, there should be a property that is empty, NHibernate automatically sets the default value, I think it should be like this????
Then, after assigning the UpdateTime attribute that was not originally assigned,found that there was no error, and then inserted the data table,
However, my field can be empty, what should I do???
Find the UpdateTime property under the class DateTime and set it to DateTime? That is, allow for emptiness. (In the mapped xml is best, also set to not-null="false", as follows:)
Finally, success, take a screenshot of the database!
|