Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I convert a DataRow array to a DataTable without iteration?

Tags:

c#-2.0

How can I convert a DataRow array to a DataTable without iteration?

like image 945
sumana shabeeb Avatar asked Dec 22 '22 04:12

sumana shabeeb


2 Answers

You can use:

dataTable = datarowarray.CopyToDataTable()

but ensure that datarowarray has length > 1, otherwise it will end up with unwanted exceptions.

like image 81
Vinoth Avatar answered May 09 '23 23:05

Vinoth


I dont think you can put an array of datarows to a datatable. You can import one row at a time using DataTable.ImportRow.

foreach(DataRow row in dataRowArray)
{
   dataTable.ImportRow(row);
}
like image 29
Ashish Gupta Avatar answered May 10 '23 00:05

Ashish Gupta