将所选数据从DataTable复制到另一个DataTable [英] Copy selected data from DataTable to another DataTable

查看:185
本文介绍了将所选数据从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...

这篇关于将所选数据从DataTable复制到另一个DataTable的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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