This article is a mirror article of machine translation, please click here to jump to the original article.

View: 22861|Reply: 0

[Source] SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999

[Copy link]
Posted on 6/29/2016 12:08:36 PM | | | |
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!






Previous:Could not compile the mapping document: xxx.hbm.xml
Next:Flush understanding of ISession in NHibernate
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com