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

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

+3
source share
4 answers

You can use:

dataTable = datarowarray.CopyToDataTable()

but be sure to have datarowarrayit length > 1, otherwise it will end with unwanted exceptions.

+9
source

I don't think you can put an array of datarows in a datatable. You can import one row at a time using DataTable.ImportRow.

foreach(DataRow row in dataRowArray)
{
   dataTable.ImportRow(row);
}
+1
source

.NET framework,

myDataTable.LoadRows(dataRowArray)

... , , hide . ( - gee-whiz smart, ).

0
    DataTable dt = new DataTable();
    DataRow[] dataRowArray = dt.Select("");
    DataTable dataTable = new DataTable();
    foreach (DataRow row in dataRowArray)
    {
        dataTable = dataTable.Clone();
        dataTable.ImportRow(row);
    }
-1

Source: https://habr.com/ru/post/1739252/


All Articles