I got an error today when I tried to fill a dataset. (dataset.Fill;)
“Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.”
There must be a value in one of the fields that is not following the table constraints. In my case, it was a field with a null value but the stored procedure that the application was calling, defined a table that restricted null values in that field. Trying running the SQL that is being called in Query Analyzer and see what kind of data you get back. One way of bypassing the contraints on the dataset is to set the EnforceConstraints property to false.
mydataset.EnforceConstraints = false;
You can do this to bypass the error or an alternative is to change the SQL constraints. In my scenario, I added a Default value of 0 (zero) on the field where the table was being defined.
CREATE TABLE myTable myColumn1 INT DEFAULT 0 myColumn2 INT NOT NULL DEFAULT 0