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

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.ConstraintException: Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.

Source Error:

 
Line 204:            'fill dataset
Line 205:            daStates.Fill(DsStatesGuests1)
Line 206:            daGuests.Fill(DsStatesGuests1)
Line 207:            'bind the drop down list
Line 208:            Me.DataBind()

 

 

If you get this error, you may need to check the key fields in your relationship to make sure that the primary key and foreign key matches up.

 

1.  Click on your .xsd file in the solution explorer.

2.  Right-click on the diamond between the two tables and select edit relation.

3.  Under the “Fields” section, make sure that the “key fields” and the “foreign key fields” match up.

 

Note:  The field does not have to be the same name, but the data in the fields must match up.