This is a migrated thread and some comments may be shown as answers.

IDENTITY_INSERT is set to OFF

4 Answers 272 Views
Data Access Free Edition
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Nathan
Top achievements
Rank 1
Nathan asked on 22 Nov 2011, 02:57 AM
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)

4 Answers, 1 is accepted

Sort by
0
Ivailo
Telerik team
answered on 23 Nov 2011, 01:54 PM
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. 
0
Nathan
Top achievements
Rank 1
answered on 28 Nov 2011, 11:14 PM
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
0
Nathan
Top achievements
Rank 1
answered on 29 Nov 2011, 12:36 AM
I think it was updating the wrong database from the config. is there a way to set and save the connections strings?
0
Ivailo
Telerik team
answered on 29 Nov 2011, 04:20 PM
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. 
Tags
Data Access Free Edition
Asked by
Nathan
Top achievements
Rank 1
Answers by
Ivailo
Telerik team
Nathan
Top achievements
Rank 1
Share this question
or