How to copy rows from one datatable to another datatable with same schema without for each loop

I have two Data Tables as DtSource and DtDestination with same schema. I want to append the rows from DtSource to DtDestination and this should be done without for each loop as DtSource data table has 50000+ rows and looping through 50000+ rows takes a lot of time.

In .NET we can use DtDestination.Merge(DtSource). But when trying to use invoke Code and passing DtSource and DtDestination as arguements and code as DtDestination.Merge(DtSource) I’m getting error “Invoke code: Exception has been thrown by the target of an invocation.”

Can anyone help me achieve this without using for each loop please

@Meghdut_Saha

Merge Datatable where you can specify the source and destination

Hope this may help you

Thanks

I thought Merging is for when the columns are different or the order of columns are different. Does it append only the rows when the columns are identical and order is same? If it does, I’m sorry for asking this silly question.

@Meghdut_Saha

Check this example:

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.