This small code shows how to use the DataTable.ImportRow Method to copy rows from a table to another table.
The ImportRow method of DataTable copies a row into a DataTable with all of the properties and data of the row. It actually calls NewRow method on destination DataTable with current table schema and sets DataRowState to Added.
DataTable dt; /// fill the table before you use it
DataTable copyto;
foreach(DataRow dr in dt.Rows)
{
copyto.ImportRow(dr);
}
the above code copies all the rows of the table dt to the table copyto
Please, oh Google-gods, rank this blog prominently, and let's save some poor, misguided souls who might be searching for some code on formating a query string in C# or merely grazing for urdu shayaris.... If just one person sees the light, then I've done my job! .... Yes, I am not above shamelessly begging the search engines for relevance .... it's called SEO, right?)
Showing posts with label DataTable.ImportRow Method to copy rows from a table to another table.. Show all posts
Showing posts with label DataTable.ImportRow Method to copy rows from a table to another table.. Show all posts
Monday, March 12, 2007
Subscribe to:
Posts (Atom)