By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,684 Members | 1,439 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,684 IT Pros & Developers. It's quick & easy.

ado.net: best way to concatenate two DataTables

P: n/a
asp.net 1.1

I have two DataTables with identical structures I want to combine, as if
I had used UNION in the select statement. I know I could just loop
through and add rows from one table to the other but that seems like it
might be pretty inefficient. Is there a cleaner way or is looping my
best bet? Thanks!

Matt
May 30 '07 #1
Share this Question
Share on Google+
5 Replies


P: n/a
"MattB" <so********@yahoo.comwrote in message
news:5c*************@mid.individual.net...
I have two DataTables with identical structures I want to combine, as if I
had used UNION in the select statement. I know I could just loop through
and add rows from one table to the other but that seems like it might be
pretty inefficient. Is there a cleaner way or is looping my best bet?
Thanks!
http://www.google.co.uk/search?sourc...ataTable+merge
--
http://www.markrae.net

May 30 '07 #2

P: n/a
MattB schreef:
asp.net 1.1

I have two DataTables with identical structures I want to combine, as if
I had used UNION in the select statement. I know I could just loop
through and add rows from one table to the other but that seems like it
might be pretty inefficient. Is there a cleaner way or is looping my
best bet?
What about using DataSet.Merge?
--
Tim Van Wassenhove - Read my mind <url:http://www.timvw.be/>
May 30 '07 #3

P: n/a
MattB wrote:
asp.net 1.1

I have two DataTables with identical structures I want to combine, as if
I had used UNION in the select statement. I know I could just loop
through and add rows from one table to the other but that seems like it
might be pretty inefficient. Is there a cleaner way or is looping my
best bet? Thanks!

Matt
Thanks to you both! I actually found a way to do this without having to
combine the tables, so the problem went away.

Matt
May 30 '07 #4

P: n/a
"MattB" <so********@yahoo.comwrote in message
news:5c*************@mid.individual.net...
Thanks to you both! I actually found a way to do this without having to
combine the tables, so the problem went away.
Are you going to share it with the group...?
--
http://www.markrae.net

May 30 '07 #5

P: n/a
Mark Rae wrote:
"MattB" <so********@yahoo.comwrote in message
news:5c*************@mid.individual.net...
>Thanks to you both! I actually found a way to do this without having
to combine the tables, so the problem went away.

Are you going to share it with the group...?

No. But only because it doesn't really apply to the original question.
Basically it boiled down to a better SQL query using UNION instead of
two distinct queries.

Matt
Jun 13 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.