DataTable.Update throws "duplicate value cannot be inserted into a unique index"
-
I have an issue with ADO.NET that I have been trying to resolve for some time now. No one at the MSDN forums seems to know what is going on so I thought I would check here. Check out this post and tell me what you think. http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/ad5910d2-7f13-47d7-8cbe-df39e850982f[^] Thanks.
-
I have an issue with ADO.NET that I have been trying to resolve for some time now. No one at the MSDN forums seems to know what is going on so I thought I would check here. Check out this post and tell me what you think. http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/ad5910d2-7f13-47d7-8cbe-df39e850982f[^] Thanks.
Well, you don't have much of a choice but to process all deletes first, then go through and add the rows. The TableAdapter goes through the rows, one-by-one and processes them according to their state. If, by chance, you've added a row to a dataset, then you've pretty much duplicated a key because the adapter hasn't gotten to the deleted row yet and executed the SQL for it. Normally, people don't reuse key values.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008