SqlDateTime overflow when time is correct?

2 posts, 0 answers
  1. Emily
    Emily avatar
    5 posts
    Member since:
    Nov 2015

    Posted 01 Dec 2015 Link to this post

    When updating a list of objects in my database, I am getting a SqlDateTime overflow exception on the same object(s) every time I try to call SaveChanges. Whats strange is that if I start from a blank database, those same records are added initially without issue. It is whenever I try to update them later on that I am getting these errors.


    The stack trace is as follows:


    Telerik.OpenAccess.Exceptions.DataStoreException: Update failed: System.Data.Sql
    Types.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.executeUpda
    te(Nullable`1 commandTimeout)
       at OpenAccessRuntime.Relational.conn.PooledPreparedStatement.executeUpdate(Nu
    llable`1 commandTimeout)
       at OpenAccessRuntime.Relational.RelationalStorageManager.generateUpdates(OID
    oid, Int32 index, ClassMetaData cmd, PersistGraph graph, Int32[] fieldNos, Boole
    an haveNewObjects, CharBuf s, BatchControlInfo batchControl, Boolean previousIns
    Row: GenericOID@1ebe2d8e RTVirtualMachine ID=79
    UPDATE [VirtualMachines] SET [BootFree] = ?, [BootTotal] = ?, [DataFree] = ?, [D
    ataTotal] = ?, [HostName] = ?, [IsActive] = ?, [Memory] = ?, [OsVersion] = ?, [P
    rocessorTimeStamp] = ?, [ProcessorUsagePct] = ?, [UserCount] = ?, [VCpuCount] =
    ?, [VmName] = ? WHERE [ID] = ? AND [BootFree] = ? AND [BootTotal] = ? AND [DataF
    ree] = ? AND [DataTotal] = ? AND [HostName] = ? AND [IsActive] = ? AND [Memory]
    = ? AND [OsVersion] = ? AND [ProcessorTimeStamp] = ? AND [ProcessorUsagePct] = ?
     AND [UserCount] = ? AND [VCpuCount] = ? AND [VmName] = ?
    Params: [@p0=0 @p1=0 @p2=0 @p3=0 @p4="RT-VM-Host7" @p5=1 @p6=11999 @p7=2008 @p8=
    0001-01-01T00:00:00.0000000 @p9=0 @p10=24 @p11=5 @p12="TSERVER3" @p13=79 @p14=0
    @p15=0 @p16=0 @p17=0 @p18="RT-VM-Host7" @p19=1 @p20=11999.0000000000 @p21=2008 @
    p22=2015-12-01T12:58:35.5300000 @p23=0 @p24=25 @p25=5 @p26="TSERVER3"] System.Da
    ta.SqlTypes.SqlTypeException: SqlDateTime overflow. Must be between 1/1/1753 12:
    00:00 AM and 12/31/9999 11:59:59 PM.

    Usually when I got an exception, the parameters in the stack trace would look normal, showing @p1, @p2, etc etc but for this particular case they are all showing as question marks in the stack trace and I am not sure why or if it has anything to do with the error I am getting here.

    The parameter in question is @p22, which as you can see is a DateTime that is well within the limits of the SqlDateTime, unless I am reading that wrong.

     What else could cause this?

  2. Emily
    Emily avatar
    5 posts
    Member since:
    Nov 2015

    Posted 01 Dec 2015 in reply to Emily Link to this post

    Actually I just noticed that one of my date times is null which is defaulting to DateTime.Min in c#. I cannot edit my post or delete it but I think thats what my issue is.
  3. DevCraft banner
Back to Top