Merging datasets

  • Thread starter Thread starter Dan Cooper
  • Start date Start date
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.
 
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
 
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.
 
Back
Top