Strongly Typed DataSet with Foreign Key Relation missing the foreign key in the rows
Posted on 2005-04-23
I have a strongly typed dataset that i have drawn in my project and it must remain strongly typed.
It has a product table with a primary key. It also has a column with a foreign key called DescriptionID which points to a DescriptionID in the Descriptions table because mutiple products could have the same description in my project. In the dataset schema designer i have draged and dropped this relation and defined it and it all works and is fine and tested out well. So I think I have described the very simplest standard relation.
The issue is when the Products table references a DescriptionID that does not exist in the Descriptions table however this might have happened. Perhaps the DescriptionID existed at some time but it was erased later by accident or some other reason.
When i use an sqldataadapter to fill the dataset Products table it throws an error "failed constraints etc etc etc" because a DescriptionID is being referenced that does not exist. If i fix the row so that it references a DescriptionID that does exist all works smoothly. However life is not perfect and I need to know what to do to stop the page from failing if a DescriptionID is missing when using a strongly typed dataset.