Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints


This issue occurs if there are errors with the referential integrity between data tables in a typed data set.  The problem is that although it raises an exception, it is difficult to see what the actual problem was (it could be nullable fields, key violations or data type violations).  What you can do to get the actual violation error message is to use the GetErrors() method on the particular data table that had the issue as below.


TypedDataSet.TableName.GetErrors()


This will return an array of errors.  In the immediate window, you can call this method and inspect the error while debugging as below:


TypedDataSet.TableName.GetErrors()[0]


 

Skip to main content