﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » StrataFrame Application Framework - V1 » Business Objects and Data Access (How do I?)  » HELP.... Cannot insert explicit value for identity column in table when IDENTITY_INSERT is set to OFF.</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Mon, 25 May 2026 01:06:02 GMT</lastBuildDate><ttl>20</ttl><item><title>HELP.... Cannot insert explicit value for identity column in table when IDENTITY_INSERT is set to OFF.</title><link>http://forum.strataframe.net/FindPost32740.aspx</link><description>By default the table has an auto incrementing primary key. I need to be able to specify the primary key in the insert command. I checked the insert statement being sent to the backend and that insert statement looks good. I must be missing something. Why am I getting this error?&lt;br/&gt;&lt;br/&gt;string strSQL = "set identity_insert tblIndividual ON ";&lt;br/&gt;ExecuteNonQuery(strSQL);&lt;br/&gt;&lt;br/&gt;this.PrimaryKeyIsAutoIncremented = false;&lt;br/&gt;this.PrimaryKeyIsUpdatable = true;&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br/&gt;this.Add();&lt;br/&gt;this.Individual_First = "John";&lt;br/&gt;this.Individual_Last = "Doe";&lt;br/&gt;this.Individual_Key = 12345;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Primary Key&lt;br/&gt;this.Save();&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ---------------&amp;gt; this line gets the error&lt;br/&gt;&lt;br/&gt;-------------------------------------------------------------------------------------------------&lt;br/&gt;DataLayerSavingException&lt;br/&gt;&amp;nbsp; Cannot insert explicit value for identity column in table 'tblIndividual' when IDENTITY_INSERT is set to OFF.&lt;br/&gt;SqlException&lt;br/&gt;&amp;nbsp; Cannot insert explicit value for identity column in table 'tblIndividual' when IDENTITY_INSERT is set to OFF.&lt;br/&gt;&lt;br/&gt;Source&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : MicroFour StrataFrame Business&lt;br/&gt;-------------------------------------------------------------------------------------------------&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;string strSQL = "set identity_insert tblIndividual OFF ";&lt;br/&gt;ExecuteNonQuery(strSQL);&lt;br/&gt;&lt;br/&gt;this.PrimaryKeyIsAutoIncremented = true;&lt;br/&gt;this.PrimaryKeyIsUpdatable = false;</description><pubDate>Thu, 13 Nov 2014 06:35:23 GMT</pubDate><dc:creator>Ross L Rooker, Sr.(1)</dc:creator></item><item><title>RE: HELP.... Cannot insert explicit value for identity column in table when IDENTITY_INSERT is set to OFF.</title><link>http://forum.strataframe.net/FindPost32742.aspx</link><description>Not using a stored procedure.</description><pubDate>Thu, 13 Nov 2014 06:35:23 GMT</pubDate><dc:creator>Ross L Rooker, Sr.(1)</dc:creator></item><item><title>RE: HELP.... Cannot insert explicit value for identity column in table when IDENTITY_INSERT is set to OFF.</title><link>http://forum.strataframe.net/FindPost32741.aspx</link><description>Hi Ross,&lt;br/&gt;&lt;br/&gt;Are you using using Stored Procedures (sp) to insert records in this BO?&lt;br/&gt;&lt;br/&gt;If so and the sp was build by the SF DDT, then you will not be able to do what you want because the sp is already pre-build by the DDT with the auto-incremented setting being enabled.&lt;br/&gt;&lt;br/&gt;Assuming you are using a sp, then you will have to change the settings in the BO to not use the stored procedure and then you method should work as expected.</description><pubDate>Wed, 12 Nov 2014 18:24:32 GMT</pubDate><dc:creator>Edhy Rijo</dc:creator></item></channel></rss>