SmartDate and dates earlier than 1753 #4644
Replies: 4 comments 1 reply
-
Can you identify where the value is being (I assume) corrupted? In code or in the database? Or in the DAL? |
Beta Was this translation helpful? Give feedback.
-
Check if your code is somehow using a parameter value that is datetime instead of datetime2. Datetime has a range starting with 1753-01-01. SQL will successfully convert a datetime parameter into a datetime2 column, but the parameter type will still have the restrictions of the datetime type. |
Beta Was this translation helpful? Give feedback.
-
This project is using 'ConnectionManager' from Csla.Data. cm.Parameters.AddWithValue("@MyDate", MyDate.DBValue); Well, the above code was creating a SQL parameter of datetime (as opposed to datetime2) SqlParameter mydate = new SqlParameter
{
ParameterName = "@MyDate",
DbType = DbType.DateTime2,
Value = MyDate.DBValue,
}; It's working! Is it because Csla.Data is using System.Data.SqlClient? |
Beta Was this translation helpful? Give feedback.
-
Not related to CSLA, but we have banned the use of AddWithValue in our company. Dan Guzman wrote about the problems with using AddWithValue. Convenience comes at a cost, and this method is one of those values that has a pretty high cost. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
In one of our existing applications, an error has been reported for dates earlier than 1753. In SQL Server we are storing the date as datetime2(3) and from our Csla code we are sending the value as the DBValue of a SmartDate property.
We are on Sql server 2022 and we are using stored procs with ADO.NET.
Any ideas?
Kind regards
Beta Was this translation helpful? Give feedback.
All reactions