Hi all
Here's my issue:
I have a windows form which displays all customer information. It does that by filling all of the tables when the form loads, and this works.
I also have a 'Search' function which selects customers by criteria (such as a 'StatusID'). In both cases, the customer table (parent) is filled. However, because the customer table can contain only a partial amount of the table (because it's being filtered by the 'where' clause in its SQL query), when I then fill child tables whose FK of 'CustomerID' is not in the results of my dataset, I get the error:
"Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.".
I understand why I get this, but my problem is how do I avoid it? Do I simply set 'EnforceConstraints' to false to avoid the error and then back to true, or is there a way to fill the customer table with everyone and then apply the filter criteria (LINQ?), or an amendment I can make to my child table query (though I assume this wouldn't fix anything as the query would be checking the database, not my dataset!).
Thoughts?!
Thank you.
Here's my issue:
I have a windows form which displays all customer information. It does that by filling all of the tables when the form loads, and this works.
I also have a 'Search' function which selects customers by criteria (such as a 'StatusID'). In both cases, the customer table (parent) is filled. However, because the customer table can contain only a partial amount of the table (because it's being filtered by the 'where' clause in its SQL query), when I then fill child tables whose FK of 'CustomerID' is not in the results of my dataset, I get the error:
"Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.".
I understand why I get this, but my problem is how do I avoid it? Do I simply set 'EnforceConstraints' to false to avoid the error and then back to true, or is there a way to fill the customer table with everyone and then apply the filter criteria (LINQ?), or an amendment I can make to my child table query (though I assume this wouldn't fix anything as the query would be checking the database, not my dataset!).
Thoughts?!
Thank you.