October 23rd 2008
Microsoft reporting: Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.
This error was bugging
me for a long time until I found this excellent forum discussion:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=541116&SiteId=1
The following points summarize the causes and solutions from the forum and offer some additional help:
1. Check if you have changed the length of any fields in the underlying database table after creating the dataset. If you have, you may need to manually change them in the dataset as well. If you are using Visual Studio 2008, open the xsd file and click on the relevant field name. Ensure the maxlength property matches your new field length.
2. If you base your dataset off a view rather than a table, and that view contains a primary key field from the underlying table, visual studio may set unique to true for that field. If your view is constructed in such a way that the field is not unique, then the error will occur. In Visual Studio 2008, open the xsd file, click on the field and set unique to false in properties.
There were other causes of the error but these seemed to be the two most common.
Cheers,
Grant
