ado.net: best way to concatenate two DataTables

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