Default DateTime column with GETDATE()

2 posts, 0 answers
  1. BekirSami
    BekirSami avatar
    12 posts
    Member since:
    Sep 2010

    Posted 23 Dec 2010 Link to this post

    Hi,
    I have a notnull DateTime column named InsertedDate and its Default Value is GETDATE() for getting server time for inserting new values automatically. At Code behind I do not assign this column.

    In model scheme explorer I select "backend calculated". But  gives error when inserting to db.
    Is there any way to succeed this.

    Insert of '2127628280-' failed: Telerik.OpenAccess.RT.sql.SQLException: The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value.
    The statement has been terminated.
       at Telerik.OpenAccess.RT.Adonet2Generic.Impl.PreparedStatementImp.execute()
       at OpenAccessRuntime.Relational.conn.PooledPreparedStatement.execute()
       at OpenAccessRuntime.Relational.RelationalStorageManager.generateInserts(NewObjectOID oid, Int32 index, ClassMetaData cmd, PersistGraph graph, Int32[] fieldNos, CharBuf s, Object[] oidData, IntArray toUpdateIndexes)
    INSERT INTO [UserPasswordHistory] ([InsertedBy], [InsertedDate], [OldPassword], [UserId]) VALUES (?, ?, ?, ?)
    select scope_identity()
    (set event logging to all to see parameter values) Telerik.OpenAccess.RT.sql.SQLException: The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value.
    The statement has been terminated.
       at Telerik.OpenAccess.RT.Adonet2Generic.Impl.PreparedStatementImp.execute()
       at OpenAccessRuntime.Relational.conn.PooledPreparedStatement.execute()
       at OpenAccessRuntime.Relational.RelationalStorageManager.generateInserts(NewObjectOID oid, Int32 index, ClassMetaData cmd, PersistGraph graph, Int32[] fieldNos, CharBuf s, Object[] oidData, IntArray toUpdateIndexes)
  2. Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 27 Dec 2010 Link to this post

    Hello Hasan,

    The IsBackendCalculated option is actually used for autoinc primary key columns. In case of a column that is not a primary key but is still populated by the server, you will have to use another option that is set on the class' property and not on the column itself. Just open the diagram, select the InsertedDate property and change the Kind option to PersistentReadOnly. This way OpenAccess will not try to persist the value of this property but you will still be able to read it. Hope that helps.

    All the best,
    Alexander
    the Telerik team
    Accelerate your learning with industry's first Telerik OpenAccess ORM SDK. Download today.
  3. DevCraft banner
Back to Top