StrataFrame Forum
Back
Login
Login
Home
»
StrataFrame Application Framework - V1
»
Business Objects and Data Access (How do I?)
»
HELP.... Cannot insert explicit value for identity column in table...
HELP.... Cannot insert explicit value for identity column in table when IDENTITY_INSERT is set to...
Post Reply
Like
1
HELP.... Cannot insert explicit value for identity column in table...
View
Flat Ascending
Flat Descending
Threaded
Options
Subscribe to topic
Print This Topic
RSS Feed
Goto Topics Forum
Author
Message
Ross L Rooker, Sr.(1)
Ross L Rooker, Sr.(1)
posted 10 Years Ago
ANSWER
Post Details
Share Post
Group: StrataFrame Users
Posts: 50,
Visits: 163
Not using a stored procedure.
Reply
Like
1
Edhy Rijo
E
Edhy Rijo
posted 10 Years Ago
ANSWER
Post Details
Share Post
E
Group: StrataFrame Users
Posts: 2.4K,
Visits: 23K
Hi Ross,
Are you using using Stored Procedures (sp) to insert records in this BO?
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.
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.
Edhy Rijo
Reply
Like
1
Ross L Rooker, Sr.(1)
Ross L Rooker, Sr.(1)
posted 10 Years Ago
ANSWER
Topic Details
Share Topic
Group: StrataFrame Users
Posts: 50,
Visits: 163
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?
string strSQL = "set identity_insert tblIndividual ON ";
ExecuteNonQuery(strSQL);
this.PrimaryKeyIsAutoIncremented = false;
this.PrimaryKeyIsUpdatable = true;
this.Add();
this.Individual_First = "John";
this.Individual_Last = "Doe";
this.Individual_Key = 12345; // Primary Key
this.Save(); ---------------> this line gets the error
-------------------------------------------------------------------------------------------------
DataLayerSavingException
Cannot insert explicit value for identity column in table 'tblIndividual' when IDENTITY_INSERT is set to OFF.
SqlException
Cannot insert explicit value for identity column in table 'tblIndividual' when IDENTITY_INSERT is set to OFF.
Source : MicroFour StrataFrame Business
-------------------------------------------------------------------------------------------------
string strSQL = "set identity_insert tblIndividual OFF ";
ExecuteNonQuery(strSQL);
this.PrimaryKeyIsAutoIncremented = true;
this.PrimaryKeyIsUpdatable = false;
Reply
Like
1
GO
Merge Selected
Merge into selected topic...
Merge into merge target...
Merge into a specific topic ID...
Open Merge
Post Reply
Like
1
Similar Topics
Post Quoted Reply
Reading This Topic
Login
Login
Remember Me
Reset Password
Resend Validation Email
Login
Explore
Messages
Mentions
Search