DataSet.Merge - Merging Errors
-
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:
-
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:
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
-
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
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