Datatable methods

Hi RPA Dev Advanced! Big fat question!

im searching info about how to use datatable methods into uipath without letting everything to the activities. I know we have all this activities:

image

BUT!.. I’m searching how to use this with codes… for example:

EX 1:
If I want to search for one value of one row into my dataTable:
dt.Select("[HeaderName]=‘Value’")
it gives me an array of dataRows that I can iterate

EX 2:
if I want to calculate some items from a column I use this:
dt.Compute(“SUM(HeaderName)”,"")

BUT!.. I dont know how to merge one table with another or look for duplicate items
I’ve tried to use this for merge 2 datatables but it shows an error:
dt.Merge(dt2,False,missingSchemaAction.Add)

The error says: “The expression don’t show any result” or something like that with an alert image icon so I cannot execute the code.

I want to understand how to use codes like this, that’s the reason i’m not using activities.
I hope you can help me with this because I was searching info about the microsoft’s documentation but it is a little different to use into Uipath sometimes.
Thank you

1 Like

Sorry, I’ve found a solution so I’ll update a little bit this:

If I want to merge all rows in two datatables I use this:
dt.AsEnumerable.Union(dt2.AsEnumerable()).CopyToDataTable

If I want to apped specific row from other dt to my main data table I use this:
dt.AsEnumerable.Append((dt2.AsEnumerable)(0)).CopyToDataTable

If I have repeated several rows in both tables and I just want to show repeat values in just one row I use this:
dt.AsEnumerable.Union(dt2.AsEnumerable()).Distinct(DataRowComparer.Default).CopyToDataTable

and if I want to delete the repeated rows completely from the table I use this:
dt.AsEnumerable().Except(dt2.AsEnumerable(), DataRowComparer.Default).CopyToDatatable

If you know other things about the tricks we have on DataTables please let me know :blush:

9 Likes

How can i add a column to the existing data table?

You have add data column activity to do so.

1 Like