appending rows to datatable

G

Guest

Hi all,

This is the way to append the rows from one datatable into another with the
same schema.

Here Temp and Temp1 are the datatables

For Each rows As DataRow In tempTable.Rows
Temp1 .NewRow()
Temp1 .ImportRow(rows)
Next

-Vignesh.S
 
O

Ollie Riches

check out ItemArray on the DataRow class

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfsystemdatadatarowclassitemarraytopic.asp

something like:

foreach(Datarow row in Table1.Rows)
{
DataRow newRow = Table2.NewRow();
newRow.ItemArray = row.ItemArray;
}

--
HTH

Ollie Riches
http://www.phoneanalyser.net

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a programmer
helping programmers.
 
O

Ollie Riches

should have been

foreach(Datarow row in Table1.Rows)
{
DataRow newRow = Table2.NewRow();
newRow.ItemArray = row.ItemArray;

Table2.Rows.Add(newRow);
}

Ollie Riches
 

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

Top