Nila Nila - 3 months ago 50
C# Question

Simple way to convert datarow array to datatable

I want to convert a

DataRow
array into
DataTable
... What is the simplest way to do this?

Answer

Why not iterate through your DataRow array and add (using DataRow.ImportRow, if necessary, to get a copy of the DataRow), something like:

foreach (DataRow row in rowArray) {
   dataTable.ImportRow(row);
}

Make sure your dataTable has the same schema as the DataRows in your DataRow array.