IDENTITY_INSERT is set to OFF

5 posts, 0 answers
  1. Nathan
    Nathan avatar
    13 posts
    Member since:
    Nov 2011

    Posted 21 Nov 2011 Link to this post

    Not sure why this is happening all of a sudden. Any help appreciated thanks.

    Insert of '882760022-0' failed: Telerik.OpenAccess.RT.sql.SQLException: Cannot insert explicit value for identity column in table 'tblProject' when IDENTITY_INSERT is set to OFF.
       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 [tblProject] ([ProjectAdd1], [ProjectAdd2], [ProjectCountry], [ProjectDescription], [ProjectID], [ProjectName], [ProjectPostcode], [ProjectState], [ProjectSuburb], [ProjectWebsite]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
    (set event logging to all to see parameter values) Telerik.OpenAccess.RT.sql.SQLException: Cannot insert explicit value for identity column in table 'tblProject' when IDENTITY_INSERT is set to OFF.
       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. Ivailo
    Admin
    Ivailo avatar
    318 posts

    Posted 23 Nov 2011 Link to this post

    Hi Nathan,

    This error might be caused by a wrong setup of the Domain Class in your Domain Model, if you have selected the Identity Mechanism as DatabaseServerCalculated and you are trying to insert explicitly a value in the primary key column.

    Can you check what is the object that you are trying to insert when the exception is thrown and verify that it's Identity Mechanism is correctly setup as per your database and business logic?

    I am looking forward to your feedback.

    Best wishes,
    Ivailo
    the Telerik team
    Want to use Telerik OpenAccess with SQL Azure? Download the trial version today. 
  3. DevCraft banner
  4. Nathan
    Nathan avatar
    13 posts
    Member since:
    Nov 2011

    Posted 28 Nov 2011 Link to this post

    Hi thanks I still seem to be having some difficulties I am unable to get the ID field to be set in SQL 2008 to IsIdenttity = True & Seed = 1 should this be set from the model when creating the DB is there a setting that is making this happen? Thanks
  5. Nathan
    Nathan avatar
    13 posts
    Member since:
    Nov 2011

    Posted 28 Nov 2011 Link to this post

    I think it was updating the wrong database from the config. is there a way to set and save the connections strings?
  6. Ivailo
    Admin
    Ivailo avatar
    318 posts

    Posted 29 Nov 2011 Link to this post

    Hi Nathan,

    Yes, you can change the connection strings in your app.config or web.config files. Find the connection string under the ConnectionStrings node. After you change it (make sure that it is in sync in all of your projects) the Domain Model wizards will consider the new values when updating the database, so your problem should be resolved.

    To double check this, open the RLINQ file with an XML or text editor and search for your connection string by name (AppConfigConnectionPropertyName node) - after a wizard has been executed to update the database, the connection string value (AppConfigConnectionString node) should be updated.

    Do not hesitate to let us know if you need any further assistance.

    Best wishes,
    Ivailo
    the Telerik team
    Want to use Telerik OpenAccess with SQL Azure? Download the trial version today. 
Back to Top
DevCraft banner