Steam
Steam

Reputation: 9866

Error in selecting from a Datatable and copying the DataTable

I tried to sort a datatable. To do that, you sort it and then copy the sorted one into a datatable, as shown here - How to query a DataTable in memory to fill another data table

code -

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

In visual studio, i see 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?)

How do I fix this ?

Upvotes: 0

Views: 851

Answers (2)

Suyash Khandwe
Suyash Khandwe

Reputation: 396

Which framework are you using? If I'm not wrong, CopyToDataTable is supported only in ver. 3.5 and above.

Upvotes: 1

MarcinJuraszek
MarcinJuraszek

Reputation: 125660

Add reference to System.Data.DataSetExtensions.dll in your project.

How to: Add or Remove References By Using the Add Reference Dialog Box

Upvotes: 2

Related Questions