Click here to Skip to main content
15,881,635 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm getting a "Cannot insert duplicate key row in object 'dbo.Formats' with unique index 'IX_FORMATS'". Naturally I looked for the duplicate key that was being added, but there is no duplicate!? :confused: I have commented out all but the bare minimum code to remove anything extraneous.

The key in question is a 5 part primary key, CString, INT64, INT64, INT64, int. The step before the error, I am modifying the last piece of the row/key (the int) by incrementing it by one and updating the table. Next step is to add a new row to the table using the old key that was just incremented.

I commented out the Begin Transaction and Commit Transaction so I could track what was happening in the table itself. When I look at the table as I step through the code, the data is accurately and appropriately updated, so that the old key does not exist. But then when I try to add the record to the table, I get the error. WTF???

To satisfy myself I added some code to re-query the table and step through each row, looking at what values are present and all checks out. It's like the indexes need to be rebuilt, but haven't yet or something?

Any suggestions?

Thanks in advance.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900