Errors caused by invalild dates in the SalesLogix entity model

Working with non-nullable types in C# can be a bit of a pain.  In the world of SalesLogix you may occasionally run into an error like this:

The key to this error is the part about “Data value overflowed the type used by the provider “.  How do you know?  Well trust me it is.  We can take a look at how to demonstrate this error with these simple lines of code:

Sage.Entity.Interfaces.IAccount account = this.BindingSource.Current as Sage.Entity.Interfaces.IAccount;
account.CreateDate = DateTime.MinValue; //1/1/0001
account.Save();

Attempting to run this code will result in a more verbose error than shown in the screen shot but still caused by the same underlying problem:

The statement has been terminated. : The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value.

This error is being caused by a date value that is out of range of the DateTime data type used by the SalesLogix OLE DB provider.  The SalesLogix provider uses the SQL Server DATETIME data type which only supports years  1753-9999. 

C# on the other hand, represents a date as the C# DateTime data type.  This is equivalent to the SQL Server 2008 DATETIME2 data type which accepts a date range of “0001/01/01” through “9999/12/31”.

When attempting to store a date that is outside the DATETIME data type (1753-9999) you will get the errors “data value overflowed the type used by the provider” or “conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value”.

Based on just the on screen error shown above, you cannot be sure where this data conversion error occurred.  If you look on the web server in the Event Logs under Application you should see an error log entry with hopefully more details as to where this failure occurred.  If you can find where the error occurred, take a look there and you will find it contains some date that is not within the 1753-9999 year date range or is blank.

ABOUT THE AUTHOR

Kris Halsrud

Kris Halsrud is a Senior Analyst / Developer for Customer FX Corporation.

Submit a Comment

Your email address will not be published. Required fields are marked *

Subscribe To Our Newsletter

Join our mailing list to receive the latest Infor CRM (Saleslogix) news and product updates!

You have Successfully Subscribed!