Cannot insert explicit value for identity column


Author
Message
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Glad you got it figured out Smile
Buluc Celik
Buluc Celik
StrataFrame Beginner (3 reputation)StrataFrame Beginner (3 reputation)StrataFrame Beginner (3 reputation)StrataFrame Beginner (3 reputation)StrataFrame Beginner (3 reputation)StrataFrame Beginner (3 reputation)StrataFrame Beginner (3 reputation)StrataFrame Beginner (3 reputation)StrataFrame Beginner (3 reputation)
Group: Forum Members
Posts: 3, Visits: 8
Thanks Trent, you pointed to the right direction. I have removed the PK from the FieldsToExcludeFromInsert property, then set PrimaryKeyIsAutoIncremented to TRUE and PrimaryKeyIsUpdatable to FALSE. It is working now Smile
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
If you are doing this through a BO, then you need to set the PrimaryKeyIsUpdatable property to True and the PrimaryKeyIsAutoIncremented to False.
Buluc Celik
Buluc Celik
StrataFrame Beginner (3 reputation)StrataFrame Beginner (3 reputation)StrataFrame Beginner (3 reputation)StrataFrame Beginner (3 reputation)StrataFrame Beginner (3 reputation)StrataFrame Beginner (3 reputation)StrataFrame Beginner (3 reputation)StrataFrame Beginner (3 reputation)StrataFrame Beginner (3 reputation)
Group: Forum Members
Posts: 3, Visits: 8
Hi,



I am getting the following error while trying to insert a record using businessObject1.save():



Cannot insert explicit value for identity column in table 'MyTable' when IDENTITY_INSERT is set to OFF.



I tracked the problem and found out that the SQL generated to insert the record has the auto-increment primary id field set to NULL.



Things I tried:



1. I setted the ID field to readonly from the Business Object Mapper -> same error

2. I captured the exact SQL, removed the ID field and run it on SQL Server Management Studio -> worked at that run

3. I added the ID field to FieldsToExcludeFromInsert property of the business object -> the application gave the error: Cannot create INSERT command because the updating DataTable does not contain columns for all PrimaryKeyFields.



I compared the business object I created for that application with a business object from the samples - which also has a auto-increment primary key field (cust_pk), and it seems to have the same structure. I didn't see any difference that could be the reason of the problem I am having.



I am still trying to find the problem, but any help would be very much appreciated.



Thanks,



Buluc
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search