Cannot insert duplicate key row in object

Hi Guys,


I have an issue while updating database entity,

I fetch a list of records, And update those iterating into an entity using for each loop.

In between i do some process of extracting files from zip is the  same for loop

But I get following error:-

Cannot insert duplicate key row in object 'dbo.OSUSR_SNY_DAFRAWFLEETMANAzGERDATA1' with unique index 'OSIDX_OSUSR_SNY_DAFRAWFLEETMANAGERDATA1_17SERVICESUBSCRIBER_5EMAIL_4ROLE_12OBJECTUSERID'.
The duplicate key value is (CUSTMW_7, alexa.top@gmail.com, Driver, MAD123456789012060).
The statement has been terminated


The entity i am updating has one key as foreign key.

Can anyone help me on this?


Hi Dhiraj,

From the error, seems like you'r inserting records and not updating. Also, the error is related to a composed unique index. Are you using an external DB?

A picture of the code may be useful.


Cheers,

Tiago.

Hi,


You have this error because that entry (with alexa.top@gmail.com) already exist in the database, and you have an index unique. If it is unique, you can only have one entry with that value.

If you want to have duplicate keys you need to remove the index unique property.

Hope this can help you.


Best regards,

Ricardo