将所选数据从DataTable复制到另一个DataTable

问题描述:

我想从数据表中选择一些数据,并将其复制到另一个数据表中。我在一个问题中找到答案 - 如何查询内存中的DataTable以填充另一个数据表

I want to select some of the data from a datatable and copy it into another data table. I found the answer in one question - How to query a DataTable in memory to fill another data table

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

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

This code does not work and causes the error -

'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。

I am using visual studio 2008 and .net 3.5.

确保你有正确的参考。在这里你需要System.Data.DataSetExtensions Assembly和System.Data命名空间。以下链接应该有助于...

Make sure you have the right references. In this you need System.Data.DataSetExtensions Assembly and System.Data Namespace. The following link should help...

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

祝你好运!

编辑:参考...的屏幕截图

Screenshot of Reference...