PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft ADO .NET
Merge problem
Forums
Newsgroups
Microsoft DotNet
Microsoft ADO .NET
Merge problem
![]() |
Merge problem |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
Hi,
I have a dataset that contains two tables, one holds parent entities and the other contains the Childs, there is a relation made into the dataset between the two tables to tie the primary key of the parent with the foreign in the child table. The data inside the tables are bound to a windows forms controls where the user had just alterd one of the fields from the child entities ( please note that changes had been made only into the child table and the parent hadn't been touched), When the user clicks save I get the updates from the dataset via GetChanges() method then taking that diffgram dataset and update its contents into the Database through my DAL server component, After the updates returns from the server I merge it with the original dataset again so identities, stamps and other stuff are reflected to the client , I do this by setting the EnforceConstraints property inside the dataset to false then applying merge then setting the EnforceConstraints property again to true and thus the problem occurs, the merge method generates the famous "Failed to enable constraints. One or more rows contains values violating non-null,..etc." exception. When browsing the original dataset after merge and before enabling the constraints to true I'd noticed that the table of the parent entities contains two identical rows , this row is exactly the parent row of the child rows that the user had altered! Also when browsing the updates dataset before sending it to the server I found that it contains that row from the parent table although it had not been modified by the user, it seems that ADO.NET brought them to satisfy the relation. Obviously the merge didn't realized that the two rows of the parent are the same and I don't know why, so it did duplicate the row and when the constraints are enabled later the uniqueness violation exception occurred. Any way, the question is how to get away from that exception? I appreciate your help. Many Thanks. |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

