收录日期:2021/01/28 17:13:48 时间:2012-06-17 04:28:08 标签:c#-2.0
How can I convert a DataRow array to a DataTable without iteration?
You can use:
dataTable = datarowarray.CopyToDataTable()
but ensure that datarowarray
has length > 1
, otherwise it will end up with unwanted exceptions.
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);
}
Even if there did exist a .NET framework function like
myDataTable.LoadRows(dataRowArray)
... all that would do is hide the iteration. The framework doesn't magically circumvent the iterative step (though in some cases it might be doing something gee-whiz smart to optimize it).
DataTable dt = new DataTable();
DataRow[] dataRowArray = dt.Select("");
DataTable dataTable = new DataTable();
foreach (DataRow row in dataRowArray)
{
dataTable = dataTable.Clone();
dataTable.ImportRow(row);
}
How can I convert a DataRow array to a DataTable without iteration?
How can I convert DataRow to string Array?
how to convert datarow into datatable
Simple way to convert datarow array to datatable
Can I add the same DataRow to a DataTable multiple times?
How can I convert a simple XMLList to an Array of Strings without a loop?
Is DataRow thread safe? How to update a single datarow in a datatable using multiple threads? - .net 2.0
How can I convert a vector to a cell array?
How can I convert a DataTable to an IEnumerable>?
If I'm updating a DataRow, do I lock the entire DataTable or just the DataRow?
How can i convert IQueryable to a string array?
How do I convert a DataTable to an IDatareader?
Can I use Linq to project a new typed datarow?
How can I convert a string array to a variant array in VBscript?
ADO.NET: convert a DataTable to an array of DataRows
How can I create a simple class that is similar to a datatable, but without the overhead?
How can Convert DataRowView To DataRow in C#
How can I save a DataTable to a .DBF?