PC Review Forums Newsgroups Microsoft DotNet Microsoft ADO .NET Merge problem

Reply

Merge problem

 
Thread Tools Rate Thread
Old 16-09-2006, 06:19 PM   #1
=?Utf-8?B?T2JzZXJ2ZXI=?=
Guest
 
Posts: n/a
Default Merge problem


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.


  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off