How to insert data from one datatable to another in particular row

I have a datatable 1 as

Column 1. Column2

A. 100
B. 200

C. 400
D. 500

And 2 datatable should be
Column 1. Column2

F 10
E 20

H 40
O 50

My output should be:
Column 1. Column2

F 10
B. 200
E 20

H 40
O 50

The 2 row in datatable 1 should be inserted as 2 row in datatable 2

Do you have any specific condition based on which the row from Datatable 1 should be inserted into Datatable 2?
If not , you just want the values to be updated into row (2) of Dt 1?

Yes insert in row2 of dt2

Please Follow the below steps and let me know if it works

  1. Use remove Data row and pass Dt2 and index as 1 to remove the 2nd row from Dt2.
  2. Use assign
    Create a new Data row variable , InsertRow = Dt2.newrow
  3. Use assign,
    InsertRow.ItemArray = Dt1.rows(1).ItemArray
  4. Use invoke method,
    Target Object as Dt2.rows
    MethodName as InsertAt

in the parameters , create 2 parameters

  1. Type = Datarow and pass variable created in step 2 , i.e InsertRow
  2. type = int32 and value = 1

I am getting error in insert method as datarow collection does not have public instance method name InsertAt matching the parameters types,generics type argument and generic type constraints supplied to invoke method

I have added the parameters type and value

The method name should be “InsertAt” . Please check the workflow attached here:

test1234.zip (2.9 KB)

In dt2 row i am getting the existing index row 1is removed.it should not remove any existing value it should just insert in index 1

you can comment out the “Remove Data row” activity . It wont remove the existing row from index 1

It working now

1 Like

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