Copying Data from one DataTable to Another using ImportRow
I recently have been engaged in an assignment where I had to copy large chunks of data from one DataTable to another. This article talks about how DataTable.ImportRow method may be more effective than copying direct rows.
The text of this article is not in this database — only its details are. The old site it was published on is gone, but the Internet Archive kept a copy: Copying Data from one DataTable to Another using ImportRow
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment
It is the same account you read, post and publish with — and you will come straight back to this page.

Menaka RanathungaPosted Sep 17, 2010, 12:30 AM
Thank you Mahesh Chand, You have given clear explanation and have covered overall requirement regarding this stuff.
Mordechai BendonPosted Nov 23, 2008, 11:40 AM
Dear Mahesh I wanted to copy a single row at a specified position to aanother dt. There are two items: 0 is ID 1 is Description If I use the ImportRow method it creates a new row in the dt but only copies in teh value for item 1 (the description). Item 0 (the ID) is blank!!!! ds.Tables("Prv").ImportRow(ds.Tables("ChooseMenus").Rows(intRow)) When I use the NewRow method and copy over the two items manually then it works fine. rwTemp = ds.Tables("Prv").NewRow rwTemp.Item(0) = ds.Tables("ChooseMenus").Rows(intRow).Item(0) rwTemp.Item(1) = ds.Tables("ChooseMenus").Rows(intRow).Item(1) ds.Tables("Prv").Rows.Add(rwTemp) Why doesn't the ImportRow copy both item values??? Mordechai