Adding Columns Into a Data Table Within a For Each

Hello,

I am putting together a workflow that compares the headers of two data tables in a for each loop and if they match then add the column from data table two to a new blank data table. If they do not match, add the column from data table one to the new data table.

The issue I am having is the Add data column activity taking a variable that holds the entire data column of either data tables. I can get the new data table to output the column headers but not the column data. Please see the below workflow screenshot.

Does anyone know a VB statement to capture the column data?

Thank you in advance for the help!

@shane.routon So your issue is that the variable holding column data from both the data tables. You just want to copy the column name but not column data. Correct me if I am wrong

Hi Ushu,

No, the issues is that the variable is only holding the column header and I need it to hold the header and data as the data type DataColumn.

a datacolumn datatype represents the definition of it, but not its data values

vs

this part is not clear

we would understand so far that based on the column name (comparing 2 datacolumn variables will not match as the objects are of different identities / instances) it should be added to a datatable or not.

One strategie could be to identify the datacols with common names between two datatables and creating a string array of it. Then use the DataTableVar.DefaultView.ToTable(False, arrCommonColNames) and have it into a new datatable. Any other values we cann add / merge afterwards as well

Sorry Peter, typo. I corrected the error above.

I went down the path you mention above with the string array but I had issues continuing to add columns as the bot compared headers. It seamed they would override the previous data column.