c# - 将选定的数据从 DataTable 复制到另一个 DataTable

标签 c# datatable

我想从一个数据表中选择一些数据并将其复制到另一个数据表中。我在一个问题中找到了答案 - How to query a DataTable in memory to fill another data table

DataTable table = GetDataTableResults();
DataTable results = table.Select("SomeIntColumn > 0").CopyToDataTable();

此代码不起作用并导致错误 -

'System.Array' does not contain a definition for 'CopyToDataTable' and 
no extension method 'CopyToDataTable' accepting a first argument of type 
'System.Array' could be found (are you missing a using directive or 
an assembly reference?)

我使用的是 Visual Studio 2008 和 .net 3.5。

最佳答案

确保您有正确的引用资料。在此,您需要 System.Data.DataSetExtensions 程序集和 System.Data 命名空间。以下链接应该有帮助...

http://msdn.microsoft.com/en-us/library/bb396189(v=vs.110).aspx

祝你好运!

编辑:引用屏幕截图...

enter image description here

关于c# - 将选定的数据从 DataTable 复制到另一个 DataTable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20308852/

相关文章:

angularjs - 在 Angular 数据表中如何更改每页显示记录选项

C# 在富文本框中以单独的行输出 csv 数据

c# - 如何在 C++ 和 C# 之间传递带有空字符的字符串?

c# - 用于 WinForms 插件的最佳设置方法

c# - 使用 Javascript 从 ASP.NET FileUpload 控件加载图像

jsf-2 - 带有 filterFunction 的 Primefaces 数据表日期范围过滤器

c# - C#中的面板绘图放大

jsf - 如何选择<h :dataTable> with <h:selectBooleanCheckbox>的多行

c# - 在现有数据表中添加具有顺序编号的新列的最佳方法

r - 创建一个计数器,只计算某个逻辑值并给出相同的重复次数