How to resolve CopyToDataTable is not a member of the System.Data.DataTable?

Hello Good People,

Am getting the error of CopyToDataTable is not a member of System.Data.Datatable.
I read through the different articles and they were advising that I should add


but it is already available as shown in the screenshot below.

Screenshot of the error:


That’s the linq query am trying to use.
Kindly advise on what I can do to resolve it.

Kakooza Allan Klaus


Just remove the CopyToDataTable and the column names should be inside { }


Because, DefaultView.ToTable returns a data table only

The documentation link

1 Like

its not a LINQ related Operatoras it comes from origin DataTable Class definition

CopyToDataTable is not defined by the class DataTable as the message mentioned
the above statement without CopyToDataTable already returns a datatable

When using DataSetExtensions then in some scenarios we can use the extension method e.g. a List(Of DataRow). For making this available then we would take care about the assembly reference.

we hope the case is more clear now

1 Like

After implementing the changes you advised
Now am getting the error of Column ‘TERMINAL’ does not belong to underlying table ‘DataTable’


Kindly advise on what I can change.

Hi @Kakooza-Allan-Klaus

dtCommissionData does not have a column with the name “TERMINAL”.

Check the data table columns in the debug mode by writing the following in the immediate panel.


This will list all the columns in the data table.

1 Like

Yes @kumar.varun2 your right because I deselected the Add Headers option because I was getting the error of already exists in DataTable and the resolution was to uncheck the Add Headers option.

So am wondering on how I can resolve this new error.

Let me try and do what you’ve advised and see

And I was thinking if I can use the index position instead of the column name I guess it will more stable that way.

How can I refractor my code to support that.


1 Like

Thanks @kumar.varun2,

I managed to resolve the issue following your guidelines.

I used the Read and Write Range activities without checking the Add Headers option.
And also used this query:


Substituting the column names with the column names I got using


In the immediate panel using the Debug mode.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.