Merging datasets

D

Dan Cooper

I've got two datasets, each containing a single data table.

dstDataSetA.Tables("TableA")
dstDataSetB.Tables("TableB")

I want to merge them together and delete any non-matching rows.

dstDataSetB.Merge(dstDataSetA) doesn't do this.

Any ideas or suggestions gratefully received.
 
M

Marshal Antony

Dan,
The rules for merging datasets are :
* All the columns must be present in both datasets
* The data types of all the columns in the datasets must be same
* The column name should match.
* The table also should be the same for both datasets.I mean data table
name in the dataset.
In your case check to see if the above rules satisfy and

one rule is definetly failing :
if
dstDataSetA.Tables("TableA")
dstDataSetB.Tables("TableB")
THEN
dstDataSetB.Merge(dstDataSetA) WILL NOT WORK !!
if
dstDataSetA.Tables("TableA")
dstDataSetB.Tables("TableA")
THEN
dstDataSetB.Merge(dstDataSetA) WILL WORK !!

You might be little confused..
When you fill the dataset .
Command.Fill(dstDataSetA,"TableA");

Command.Fill(dstDataSetB,"TableA");
This is the way to go..

I am not giving the full ADO.NET code which you might already know.
Hope this helps.
Regards,
Marshal Antony
http://dotnetmarshal.com
 
M

Marshal Antony

Dan Cooper said:
I've got two datasets, each containing a single data table.

dstDataSetA.Tables("TableA")
dstDataSetB.Tables("TableB")

I want to merge them together and delete any non-matching rows.

dstDataSetB.Merge(dstDataSetA) doesn't do this.

Any ideas or suggestions gratefully received.
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top