ado.net: best way to concatenate two DataTables

M

MattB

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
 
T

Tim Van Wassenhove

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?
 
M

MattB

MattB said:
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
 
M

Mark Rae

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...?
 
M

MattB

Mark said:
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
 

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,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top