Jump to content

DataConstraint Exception with Junction Table


Abbasi

Recommended Posts

I am quoting a clear example of the Junction table, in Northwind sample database.When employing this database in a DataGrid, I receive DataConstraint Exception Error in the Junction table "Order Details" or in the "Orders" table, with the following error message:"Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints."On displaying one of the errant tables, each row complains as below:"ForeignKeyConstraint, Shipper_Order (for example) requires the child key values ????? to exist in the parent table.NOTES: 1- I established Relations just according to the ones in MS Access application.2- The Same Database is Functioning normally inside MS Access application.3- I am mainly concerned about the Junction table.I need professional guidance as this is a study project, I am working on.

Link to comment
Share on other sites

I am quoting a clear example of the Junction table, in Northwind sample database.When employing this database in a DataGrid, I receive DataConstraint Exception Error in the Junction table "Order Details" or in the "Orders" table, with the following error message:"Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints."On displaying one of the errant tables, each row complains as below:"ForeignKeyConstraint, Shipper_Order (for example) requires the child key values ????? to exist in the parent table.NOTES: 1- I established Relations just according to the ones in MS Access application.2- The Same Database is Functioning normally inside MS Access application.3- I am mainly concerned about the Junction table.I need professional guidance as this is a study project, I am working on.

ForeignKeyConstraint, Shipper_Order (for example) requires the child key values ????? to exist in the parent table. I think its a database issue . the junction table might have an id where it doesn't exist in the parent table.When you are trying to delete records in the database , delete them in the child table and then in the parent table. If we dont keep track of such things integrity might fail.
Link to comment
Share on other sites

Thanks aspnetguy for the response. I found the reason of the problem. The sequence in which I filled the DataAdapters was not appropriate - the rule is load the Parent table before the Child table, otherwise meet the problem.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...