471,350 Members | 1,946 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

How to combine datasets?

I have one dataset with columns a thru c. Then another that gets
columns a and d thru f. I need a dataset that has columns a thru f.
What is the best way to do it?

I currently have a thru c in dataset1. Then I use a datareader for set
#2 and start constructing a new dataset in the reader loop.

Thanks,
Brett

Dec 22 '05 #1
2 4759
Brett,

Have you tried the ImportRow method on the DataRowCollection returned by
the Rows property on the Table? Or the Merge method on the DataSet?

If those don't work, what you could do is cycle through the rows in the
destination, creating an object array with a number of elements equal to the
columns in the destination dataset. Once you do that, you can get the
ItemArray property on the source row, and then copy those items to the
appropriate items in the array you created (only copying what you can,
because of the differences in size). Then, you can call the AddRow method
on the DataRowsCollection, passing the object array representing the values.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Brett Romero" <ac*****@cygen.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
I have one dataset with columns a thru c. Then another that gets
columns a and d thru f. I need a dataset that has columns a thru f.
What is the best way to do it?

I currently have a thru c in dataset1. Then I use a datareader for set
#2 and start constructing a new dataset in the reader loop.

Thanks,
Brett

Dec 23 '05 #2
Thanks. That's basically what I'm doing. I was just wondering if
there was a way to avoid the looping. I'm using a data reader for the
looping.

Brett

Dec 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by GaryDean | last post: by
3 posts views Thread by Imran Aziz | last post: by
2 posts views Thread by David Lozzi | last post: by
4 posts views Thread by Ronald S. Cook | last post: by
25 posts views Thread by Penelope Dramas | last post: by
12 posts views Thread by BillE | last post: by
9 posts views Thread by gardnern | last post: by
reply views Thread by XIAOLAOHU | 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.