How to select multiple column from a datatable

Hi All,

I have a data table where I have multiple columns.
I have to select some column from the data table and insert into a new data table.
I am using Invoke Code Activity and added code but it is giving me object reference is not set to be an instance of an object.

Dim abc As New DataTable()
in_DataRow = (From p In in_ExcelData.AsEnumerable() Select abc.LoadDataRow(New Object() {p.Field(Of String)(“UserID”)}, False)).ToList

1 Like


You can use the FilterDataTable Activity
In output columns Tab : specify columns you want to keep or remove
Save the Result to new Datatable



1 Like


Directly use Filter Data Table activity after getting the main data table.

select “output column” option

Then enter the names of column you wan to keep select remove option if u want to remove the columns

1 Like


Thanks for the feedback but i can not use Filter Data table Activity.
I want to do this with invoke code activity where i can write code.
Also, i have two data table and i used join with on both of the table and then i have to select some field from both table.

Hi @Ritesh123,
It may helps you.
yourdatatable.defaultview.totable(false, “Col 1 name” , “Col 2 name”)
Best Regards,
Likith Rajesh.


Good morning Ritesh,

The simplest solution would most likely be using the “Join Data Tables” activity in combination with @likith_rajesh’s solution above.