Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. DataTable.Update throws "duplicate value cannot be inserted into a unique index"

DataTable.Update throws "duplicate value cannot be inserted into a unique index"

Scheduled Pinned Locked Moved .NET (Core and Framework)
csharpdatabasecomhelpquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    gongchengshi
    wrote on last edited by
    #1

    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.

    D 1 Reply Last reply
    0
    • G gongchengshi

      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.

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups