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
  1. Home
  2. General Programming
  3. Visual Basic
  4. DataSet.Merge - Merging Errors

DataSet.Merge - Merging Errors

Scheduled Pinned Locked Moved Visual Basic
databasehelpquestion
3 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.
  • M Offline
    M Offline
    mikasa
    wrote on last edited by
    #1

    Ok, I have tried everything there is and I cannot get data to Merge into a DataSet. I have done this before, but now I am having problems with this particular piece of code. Here is the Error:

    Constraint Exception:
    System.Data.ConstraintException: Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.
    at System.Data.DataSet.FailedEnableConstraints()
    at System.Data.DataSet.EnableConstraints()
    at System.Data.DataSet.set_EnforceConstraints(Boolean value)
    at System.Data.Merger.MergeDataSet(DataSet source)
    at System.Data.DataSet.Merge(DataSet dataSet, Boolean preserveChanges, MissingSchemaAction missingSchemaAction)
    at...

    The DataSet is retrieved from the DB the first time fine. The DataSet contains 4 DataTables as well as some DataRelations. The 2nd time around, when I am trying to refresh the Data from the DB (but Preserve my changes) I get the above Error. It is absolutely impossible, beyond any doubt, that there are "NULL" values in any Primary Keys or F-Keys used within the DataRelations. What can be causing this? :mad:

    D 1 Reply Last reply
    0
    • M mikasa

      Ok, I have tried everything there is and I cannot get data to Merge into a DataSet. I have done this before, but now I am having problems with this particular piece of code. Here is the Error:

      Constraint Exception:
      System.Data.ConstraintException: Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.
      at System.Data.DataSet.FailedEnableConstraints()
      at System.Data.DataSet.EnableConstraints()
      at System.Data.DataSet.set_EnforceConstraints(Boolean value)
      at System.Data.Merger.MergeDataSet(DataSet source)
      at System.Data.DataSet.Merge(DataSet dataSet, Boolean preserveChanges, MissingSchemaAction missingSchemaAction)
      at...

      The DataSet is retrieved from the DB the first time fine. The DataSet contains 4 DataTables as well as some DataRelations. The 2nd time around, when I am trying to refresh the Data from the DB (but Preserve my changes) I get the above Error. It is absolutely impossible, beyond any doubt, that there are "NULL" values in any Primary Keys or F-Keys used within the DataRelations. What can be causing this? :mad:

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

      It's probably not a NULL value error, but your resulting dataset is violating the key constraints somehow. Possibly two records having the same key? That leads to another question...When you refresh the data, are you sure you're not appending a new copy of the data to the old version of the dataset? RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

      M 1 Reply Last reply
      0
      • D Dave Kreskowiak

        It's probably not a NULL value error, but your resulting dataset is violating the key constraints somehow. Possibly two records having the same key? That leads to another question...When you refresh the data, are you sure you're not appending a new copy of the data to the old version of the dataset? RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

        M Offline
        M Offline
        mikasa
        wrote on last edited by
        #3

        Well, I figured this one out. Since I was retrieving data from Views, it wasn't able to determine the P-Keys on its own. I modified the Tables after data retrieval to have the Proper Key Columns on them. Afterwards, it worked great! So I guess in a sense, it was trying to append the same Records twice, and since I had Relationships setup, it was violating the Constraints. ;P

        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