Add data column activity adding data column does not work as expected

Hi All,

When I try to use the add data column activity and try to pass the entire data column from other table I am not able to do that, getting some error related to add data column activity.
not using column name and not using for each, I want to use only the column property which will take only datacolumn object.

your inputs will be appreciated

Regards,
Pavan H

1 Like

Hi @pavanh003,

Can you please send the error screenshot?

You cannot copy a DataColumn. (DataColumns are very tightly coupled with their tables)

Instead, you can add a new column with the same name and datatype.

You might be looking for DataTable.Clone() , which will create a structual copy of an entire table. (With the same schema, but no data)

Hi Vivek,

Please find the below screenshot for your reference

Regards,
Pavan H

Hey,
Yes, I agree with you, then why do we have the property in add data column activity to add the data column?
Please refer the screenshot shared above for more details.

Regards,
Pavan H

If you create a datacolumn from scratch. It should work

Hi,
To create a data column we need a data table.
for that I use a build data table and create a datatable. for this case also the same error occurs.

Regards,
Pavan H

Not entirely true. You can create a new datacolumn and add them for example in a datacolumncollection.

Hi,
Yes I agree with you we can create a new data column object with out datatable.

I tried with that as well but was not able to succeed.

Regards,
Pavan H

Hi @pavanh003,

Refer the below post for reference.

Hey @anil5,

What ever you have said in the post I agree with you, so now lets say for example: I will add a data row from one table to other table, using add data row activity, will pass the data row, but I want to know how we can do the same with add data column activity to add the new data column from one table to other.

Regards,
Pavan H

1 Like

Hi @pavanh003,

Yes you can pass columns from one datatable to another datatable.

I have attached a sample workflow for you and a sample excel sheet.

  1. Sample excel sheet has 4 columns.
  2. I have created a table using build datatable activity which has 1 column.
  3. Now i have added the 4 columns of a datatable to 1 column of another datatable of build datatable.
  4. Now the resulted build datatable will have 5 columns.

So here one thing to be noted, we cannot use column property of Add data column activity we have to use column name property as we get the error the “column belongs to another datatable” when we use Column property

If you are inside for each, using column property you cannot add the columns to another table.

If you see the same thing happens in Add data row activity when you pass the row variable in Datarow property, you get the same error “this row belongs to another table”

Main.xaml (8.8 KB)

Book1 (1).xlsx (9.1 KB)

1 Like