将数据行数组转换为数据表的简单方法 [英] Simple way to convert datarow array to datatable

查看:16
本文介绍了将数据行数组转换为数据表的简单方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将 DataRow 数组转换为 DataTable ... 最简单的方法是什么?

I want to convert a DataRow array into DataTable ... What is the simplest way to do this?

推荐答案

为什么不遍历您的 DataRow 数组并添加(使用 DataRow.ImportRow,如有必要,获取 DataRow 的副本),例如:

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);
}

确保您的 dataTable 与 DataRow 数组中的 DataRows 具有相同的架构.

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

这篇关于将数据行数组转换为数据表的简单方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆