471,071 Members | 1,480 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,071 software developers and data experts.

Merging datasets

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.


Nov 18 '05 #1
2 1252
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" <da********@dontspam.com> wrote in message
news:e5**************@TK2MSFTNGP09.phx.gbl...
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.

Nov 18 '05 #2

"Dan Cooper" <da********@dontspam.com> wrote in message
news:e5**************@TK2MSFTNGP09.phx.gbl...
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.

Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Jon Bosker | last post: by
2 posts views Thread by Klatuu | last post: by
reply views Thread by Kjetil | last post: by
2 posts views Thread by Phil Townsend | last post: by
7 posts views Thread by Jon Vaughan | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.