Ralpharama Archive. The archive is almost 20 years old, this website is no longer maintained.

Home | New Writing | Old Writing | Cooking | Technical | Wine Making | Cocktails
   
 
Misc

Cannot insert explicit value error

Hits 11737 | Created 2007-06-15 | Modified 2007-06-15

This error message had me scratching my head for a few minutes:

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC SQL Server Driver][SQL Server]Cannot insert 
explicit value for identity column in table 'xxx' 
when IDENTITY_INSERT is set to OFF.

The fault in the end was that I had added a primary key and set identity to YES in the database for this table, when in fact I was trying to insert the ID key field myself!

Examine your sql...

Removing both identity and primary key works if you are inserting the key yourself. If you want an auto-generated key, then ensure that identity is turned on and that you have a seed and are auto-incrementing. And also that you aren't adding the primary key yourself!




Comment Cannot insert explicit value error comment by John Hits | Last Modified 2013-03-22
I found my answer here and it's simple:

http://www.advancesharp.com/Questions/18424/cannot-insert-explicit-value-for-identity-column-in-table-xxxxx-when-identity-insert-is-set-to-off

Make a Comment

Name
Comment


Antispam Code (always a number)

Enter Code Above
Submit

Note: All HTML will be removed except for bold and italics. Links will not display. Line breaks are added automatically. Use <pre>...</pre> for code.

Tags

This item has the following tags:
tech sql

Useful? Donate for hosting costs

All content copyright (c) Ralpharama