ADO.NET 2.0 Dataset Merge

W

Wayne Godfrey

I have a database application developed in VS 2003 that uses a dataset (ds)
containing three tables: one parent (dt1) and two child tables (dt2 & dt3).

In code I clone the two child datatables (dt2Clone & dt3Clone), make updates
to the clones, and then merge those back into the original dataset using the
following syntax:

ds.merge(dt2Clone)
ds.merge(dt3Clone)

After doing this, the original dataset still only has the 3 tables (dt1,
dt2, & dt3) and the child tables contain the merged, updated data.

When I ported this code unchanged over to Visual Studio 2005 Beta 2 it
broke.

What I found was that the merge statements mentioned above resulted not in
the data from the clone tables being merged with the original tables but
instead two additional tables were created in the dataset WITH THE SAME
NAMES. So I had dt1, dt2, dt3, dt2, and dt3.

Later, when I tried to reference dt2, I received an exception from within
the dataset's designer generated code that stated the name dt2 (or dt3) was
in the collection twice with different namespaces.

I changed the merge statements to use the datatable merge instead of the
dataset merge and it worked correctly.

ds.dt2.merge(dt2Clone)
ds.dt3.merge(dt3Clone)

Is this an intended change in the way the dataset merge works?
 
S

Sahil Malik [MVP]

Y'know I think this is a ADO.NET 2.0 bug. Try replacing the strongly typed
dataset with a simple dataset - with the same data and only the PK
constraints. See if it works. (You shouldn't have to change code to make
your Merge code work).

I have a similar situation BTW - and I just haven't had time to report this
in a cleanly segregated sample as a bug - but I think you should (since you
have it cleanly segregated).

- Sahil Malik [MVP]
Upcoming ADO.NET 2.0 book - http://tinyurl.com/9bync
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top