Copying data of only few columns to one more data table(将仅几列的数据复制到另一个数据表)
问题描述
我有一个场景,我得到一个包含 65 列和 100 行的数据表.我需要再创建一个包含所有 100 行的数据表,即与原始数据表相同,但在原始表中应该只有 65 列中的 5 列.有什么方法可以在不循环的情况下实现这一点?
I have a scenario where I get a data table with 65 columns and 100 rows. I need to create one more data table with all 100 rows, i.e. the same as the original data table but should be having only 5 columns out of 65 present in original table. Is there any way to achieve this without looping?
推荐答案
试试 DataView.ToTable 方法.
像这样使用它:
DataTable newTable = oldTable.DefaultView.ToTable(false, "ColumnName1", "ColumnName2", "ColumnName3", "ColumnName4", "ColumnName5");
这篇关于将仅几列的数据复制到另一个数据表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:将仅几列的数据复制到另一个数据表


基础教程推荐
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- 将 XML 转换为通用列表 2022-01-01
- rabbitmq 的 REST API 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01
- c# Math.Sqrt 实现 2022-01-01
- 如何激活MC67中的红灯 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01