SQL Time Data Type Support

2 posts, 0 answers
  1. Brian Levin
    Brian  Levin avatar
    11 posts
    Member since:
    Nov 2009

    Posted 02 Aug 2013 Link to this post

    Hello,

    I have a SQL 2012 database with a table containing a column of type Time(7).  I am using fluent mapping and it maps to a property of type DateTime? (since the column in the database is  nullable).  

    Inserting records into this table works fine.  The issue is when I update the record, I get the following error:

    System.Data.SqlTypes.SqlTypeException: SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.
     
    Generated: Fri, 02 Aug 2013 12:58:10 GMT
     
    Telerik.OpenAccess.Exceptions.DataStoreException: Update failed: System.Data.SqlTypes.SqlTypeException: SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.
       at Telerik.OpenAccess.RT.Adonet2Generic.Impl.PreparedStatementImp.executeUpdate()
       at OpenAccessRuntime.Relational.conn.PooledPreparedStatement.executeUpdate()
       at OpenAccessRuntime.Relational.RelationalStorageManager.generateUpdates(OID oid, Int32 index, ClassMetaData cmd, PersistGraph graph, Int32[] fieldNos, Boolean haveNewObjects, CharBuf s)
    Row: GenericOID@9d8084b1 AgendaVersion VersionId=440
    UPDATE [EventAgendaVersion] SET [EndTime]=?, [StartTime]=? WHERE [VersionId] = ? AND [EndTime]=? AND [StartTime]=?
    (set event logging to all to see parameter values) System.Data.SqlTypes.SqlTypeException: SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.
       at Telerik.OpenAccess.RT.Adonet2Generic.Impl.PreparedStatementImp.executeUpdate()
       at OpenAccessRuntime.Relational.conn.PooledPreparedStatement.executeUpdate()
       at OpenAccessRuntime.Relational.RelationalStorageManager.generateUpdates(OID oid, Int32 index, ClassMetaData cmd, PersistGraph graph, Int32[] fieldNos, Boolean haveNewObjects, CharBuf s) ---> System.Data.SqlTypes.SqlTypeException: SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.
       at Telerik.OpenAccess.RT.Adonet2Generic.Impl.PreparedStatementImp.executeUpdate()
       at OpenAccessRuntime.Relational.conn.PooledPreparedStatement.executeUpdate()
       at OpenAccessRuntime.Relational.RelationalStorageManager.generateUpdates(OID oid, Int32 index, ClassMetaData cmd, PersistGraph graph, Int32[] fieldNos, Boolean haveNewObjects, CharBuf s)
       --- End of inner exception stack trace ---
       at OpenAccessRuntime.ExceptionWrapper.Throw()
       at OpenAccessRuntime.DataObjects.OpenAccessPersistenceManagerImp.handleException(Exception x, Boolean needsRollback)
       at OpenAccessRuntime.DataObjects.OpenAccessPersistenceManagerImp.internalCommit(Boolean phase)
       at OpenAccessRuntime.DataObjects.OpenAccessPersistenceManagerImp.commit()
       at OpenAccessRuntime.DataObjects.UnsynchronizedPMProxy.commit()
       at OpenAccessRuntime.EnlistableObjectScope.CommitChanges()
       at Telerik.OpenAccess.OpenAccessContextBase.SaveChanges(ConcurrencyConflictsProcessingMode failureMode)
       at Dreamwire.Customer.Repository.Context.DreamwireCustomerContext.Dreamwire.Customer.Repository.Context.IDreamwireCustomerContext.SaveChanges()
       at Dreamwire.Customer.Services.Implementations.Events.AgendaService.Save(AgendaVersion agenda, Guid userId, Int64 eventId, Nullable`1 sessionId, Nullable`1 activityId)
       at Dreamwire.Studio.Presentation.Presenters.Events.AddEditAgendaPresenter.Save(IUserContext context)
       at Dreamwire.Studio.Web.Studio.Events.AddEditAgenda.btnSubmit_Click(Object sender, EventArgs e)
       at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
       at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
       at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
       at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
       at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
            

    So if in the existing Time field I have 08:45:00.0000000, when I request the object mapped to that table, it comes back as 01/01/0001 8:45.  When the update occurs it is trying to update WHERE TimeField = '01/01/0001 08:45' and that's when the overflow happens.

    My question is, what do I need to change to make this work correctly?  I looked into Type Converters, but I'm not really sure that will help.  Do I need to use a string or something to map it to instead of a nullable date/time?  Or am I just missing something completely?  Any help you can provide would be greatly appreciated!
  2. PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 08 Aug 2013 Link to this post

    Hi Brian,

     This should not be the case. If your already have a value in your column and we are miss reading it than this is definitely a problem however I was not able to reproduce that. Can you please share a bit more information on how exactly the issue is appearing? 
    Are you reading a row that has no value set or are you perhaps inserting a row that has the date time not set at all?

    Regards,
    Petar
    Telerik
    OpenAccess ORM Q2 2013 brings you a more powerful code generation and a unique Bulk Operations support with LINQ syntax. Check out the list of new functionality and improvements shipped with this release.
  3. DevCraft banner
Back to Top