Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Tom C 87 posts 222 karma points
    Jan 05, 2017 @ 20:26
    Tom C
    0

    Store old dates - change cmspropertydata datadate to datetype2

    I need to store datetime values earlier than 1753 .. at the moment this throws an error (as below) when trying to insert into the cmsPropertyData table. I changed the type of the column for dataDate in this table to DateTime2 hoping this would solve my problem, but unfortunately got the same error. So i think I need to change something else in the source code but im not sure what. In the file SqlSyntaxProviderBase.cs there are datamaps for DateTime columns, and maybe I need something for DateTime2?

    DbTypeMap.Set<DateTime>(DbType.DateTime, DateTimeColumnDefinition);
            DbTypeMap.Set<DateTime?>(DbType.DateTime, DateTimeColumnDefinition);
    

    Any help greatly appreciated!

    The error is;

    [SqlTypeException: SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.]
       System.Data.SqlClient.TdsParser.TdsExecuteRPC(SqlCommand cmd, _SqlRPC[] rpcArray, Int32 timeout, Boolean inSchema, SqlNotificationRequest notificationRequest, TdsParserStateObject stateObj, Boolean isCommandProc, Boolean sync, TaskCompletionSource`1 completion, Int32 startRpc, Int32 startParam) +7694
       System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest) +2031
       System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry) +911
       System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) +64
       System.Data.SqlClient.SqlCommand.ExecuteScalar() +180
       StackExchange.Profiling.Data.ProfiledDbCommand.ExecuteScalar() in c:\Code\github\SamSaffron\MiniProfiler\StackExchange.Profiling\Data\ProfiledDbCommand.cs:299
       Umbraco.Core.Persistence.<>c__DisplayClass11_0.<ExecuteScalarWithRetry>b__0() in C:\Users\Tom\Downloads\Umbraco-CMS-release-7.5.6\Umbraco-CMS-release-7.5.6\src\Umbraco.Core\Persistence\PetaPocoCommandExtensions.cs:237
       Umbraco.Core.Persistence.FaultHandling.RetryPolicy.ExecuteAction(Func`1 func) in C:\Users\Tom\Downloads\Umbraco-CMS-release-7.5.6\Umbraco-CMS-release-7.5.6\src\Umbraco.Core\Persistence\FaultHandling\RetryPolicy.cs:172
       Umbraco.Core.Persistence.PetaPocoCommandExtensions.ExecuteScalarWithRetry(IDbCommand command, RetryPolicy cmdRetryPolicy, RetryPolicy conRetryPolicy) in C:\Users\Tom\Downloads\Umbraco-CMS-release-7.5.6\Umbraco-CMS-release-7.5.6\src\Umbraco.Core\Persistence\PetaPocoCommandExtensions.cs:231
       Umbraco.Core.Persistence.PetaPocoCommandExtensions.ExecuteScalarWithRetry(IDbCommand command, RetryPolicy retryPolicy) in C:\Users\Tom\Downloads\Umbraco-CMS-release-7.5.6\Umbraco-CMS-release-7.5.6\src\Umbraco.Core\Persistence\PetaPocoCommandExtensions.cs:216
       Umbraco.Core.Persistence.PetaPocoCommandExtensions.ExecuteScalarWithRetry(IDbCommand command) in C:\Users\Tom\Downloads\Umbraco-CMS-release-7.5.6\Umbraco-CMS-release-7.5.6\src\Umbraco.Core\Persistence\PetaPocoCommandExtensions.cs:203
       Umbraco.Core.Persistence.Database.Insert(String tableName, String primaryKeyName, Boolean autoIncrement, Object poco) in C:\Users\Tom\Downloads\Umbraco-CMS-release-7.5.6\Umbraco-CMS-release-7.5.6\src\Umbraco.Core\Persistence\PetaPoco.cs:1465
       Umbraco.Core.Persistence.Database.Insert(Object poco) in C:\Users\Tom\Downloads\Umbraco-CMS-release-7.5.6\Umbraco-CMS-release-7.5.6\src\Umbraco.Core\Persistence\PetaPoco.cs:1473
       Umbraco.Core.Persistence.Repositories.ContentRepository.PersistNewItem(IContent entity) in C:\Users\Tom\Downloads\Umbraco-CMS-release-7.5.6\Umbraco-CMS-release-7.5.6\src\Umbraco.Core\Persistence\Repositories\ContentRepository.cs:402
       Umbraco.Core.Cache.DefaultRepositoryCachePolicy`2.CreateOrUpdate(TEntity entity, Action`1 persistMethod) in C:\Users\Tom\Downloads\Umbraco-CMS-release-7.5.6\Umbraco-CMS-release-7.5.6\src\Umbraco.Core\Cache\DefaultRepositoryCachePolicy.cs:80
    
Please Sign in or register to post replies

Write your reply to:

Draft