|
Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.
I saw the following solution online. But I didn't understand it too much.
For example, the second one, I did not find where I can turn off EnforceConstraints in the DataSet property.
1. First, as prompted, check whether the returned columns do not allow empty columns or duplicate values. You can also remove the PrimaryKey attribute in the DataSet, which can basically solve these two problems;
2. Turn off EnforceConstraints in the DataSet property;
3. This is my solution to the problem, and it is also encountered by most people: The default length of a field in the DataSet is smaller than the actual returned field length, so an error occurs, so as long as the MaxLength in the property is set greater than the actual Just return the length of the field. If you cannot determine the maximum length of the returned field, you can also set it to -1, which is not limited. I have to set it to -1 because it is a combination of multiple fields. .
Please master click. |
|