How can I find out which column and value is violating the constraint? The exception message isn't helpful at all:
Failed to enable constraints. One or
more rows contain values violating
non-null, unique, or foreign-key
constraints.
cdatasetnet
How can I find out which column and value is violating the constraint? The exception message isn't helpful at all:
Failed to enable constraints. One or
more rows contain values violating
non-null, unique, or foreign-key
constraints.
Best Answer
Like many people, I have my own standard data access components, which include methods to return a DataSet. Of course, if a ConstraintException is thrown, the DataSet isn't returned to the caller, so the caller can't check for row errors.
What I've done is catch and rethrow ConstraintException in such methods, logging row error details, as in the following example (which uses Log4Net for logging):