How to create a data column at specific location dynamically

how to create data column at a specific location dynamically
like without mentioning the column index can we mention like beside this column like that?


use invoke code activity to create a column dynamically


You can pass any index where you want to add the column

but the columnindex you are giving should not exceed the columns count


You cannot mentioned beside a specific column…but what you can do is get the column index ousing column name and then add 1 to it and create a column using that index

To get index of a column use assign with

Requiredindex = (From dc In dt.Columns.Cast(Of DataColumn) Select dc.ColumnName).ToArray().indexOf("RequiredColumnName")

Here requiredindex is integer type and add 1 to it to get the next column index where new column needs to be added




Try like this

Requiredindex = Array.IndexOf((From dc In dt.Columns.Cast(Of DataColumn) Select dc.ColumnName).ToArray(),"RequiredColumnName")


how should I mention in the invoke method
after the assign method


What is this .reqindex …you just need to specify the requndex +1

And pass the datatable to invoke method…please check here


I have added the material description column but its over writing the data


What do you mean?


my input data is first empty column then vala,material,totals,bun,totalv,crcy
i added material description column beside of material but the material description column didnt came empty


can you show you flow please


check this flow once.

can you check this once


is the new column not getting added or what is the issue?


Hi @anjani_priya

Create two variables

existingColumnName As String = “YourExistingColumnName”
newColumnName As String = “YourNewColumnName”

'Find the index of the existing column

columnIndex As Int32 = dtTable.Columns.IndexOf(existingColumnName)

Create the variable newColumn

newColumn As New DataColumn(newColumnName)

Add the new DataColumn to the DataTable

Use SetOrdinal to place the new column beside the existing column
This will move the new column to the position right after the existing column

If columnIndex <> -1
newColumn.SetOrdinal(columnIndex + 1)