How to copy a column from one datatable to another based on a common column

I have two datatables with a common column name. Based on this column name i want to merge 1 of the columns from the 1st datatable to another datatable.

@vvaidya @arivu96 @ovi

Hi Naresh,

Have you checked these posts related to your request?

Hi @jamnanin,

Refer this xaml file.
JoinTables.xaml (10.6 KB)


hi @arivu96 this xaml is working fine but when i do the same thing in another file unfortunately it doesnt work. I dont understand what i am doing wrong. where have you used the result and dt3 variable?

@ovi can you help me where the result file is being used coz the invoke doesnt seem to work for other files. this is the error i get
**"Main has thrown an exception

Source: Invoke method

Message: Object reference not set to an instance of an object. This error usually occurs when using a variable with no set value (not initialized).

Exception Type: NullReferenceException

System.NullReferenceException: Object reference not set to an instance of an object.
at System.Activities.Statements.MethodExecutor.InvokeAndUnwrapExceptions(Func`3 func, Object targetInstance, Object actualParameters)
at System.Activities.Statements.MethodResolver.SyncMethodExecutor.BeginMakeMethodCall(AsyncCodeActivityContext context, Object target, AsyncCallback callback, Object state)
at System.Activities.Statements.MethodExecutor.BeginExecuteMethod(AsyncCodeActivityContext context, AsyncCallback callback, Object state)
at System.Activities.Statements.InvokeMethod.BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, Object state)
at System.Activities.AsyncCodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.ActivityInstance.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)"**

Hi Naresh,

In Invoke method activity have you set the right Parameters?

yes @ovi i have set similar parameters as in the xaml file

1 Like

Could you upload your workflow please?

1 Like

join table.xlsx (10.0 KB)

I have uploaded the xaml and the sample file @oviMain.xaml (9.0 KB)

Your second Read Range activity has also the output datatable “dt1”. So when you set “dt2” as In parameter in Invoke method, it throws that error because it is not initialized.

So change the output in the second Read Range(“Sheet2”) to “dt2”.

Hope it helps!

I cleared all that but I am still getting the error. can you please update the xaml and attach it?

The issue is with the column names. Change in excel the first Id name with ID and it should work fine.

1 Like

thanks a lot @ovi

@ovi Theres a slight problem now. The columns dont merge, instead the 2nd datatable gets added below the 1st one @arivu96

hi there did you ever get a solution for this?