Add Data Column After Or Before Specific Column

Hi Guys,

Does anyone know how to add a column after or before the specific column in DataTable?

Hi @kuppu_samy

Use insert delete column activity and based on the index value you can create column

Thanks
Ashwin.S

Yes @AshwinS2 , I can do but I have 50,000 of data in the other columns. I don’t want to delete the existing data.

Hi @kuppu_samy

Do Insert coulmn and do datatable.clone

Thanks
Ashwin S

Hi @AshwinS2,

Can you give me some more detailed? Can you give me the code?

@kuppu_samy

You can use Invoke method activity and pass the parameters in the Properties.

You can use the column index number as an argument.

Hi @kuppu_samy

For example, if you have a DataTable is named dt,
and you hope that a new column “Name” be set before a specific column “Price”.

dt.Columns(“Name”).SetOrdinal(dt.Columns(“Price”).Ordinal)

or if you hope that a new column “Name” be set after a specific column “Price”.

dt.Columns(“Name”).SetOrdinal(dt.Columns(“Price”).Ordinal+1)

1 Like

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