Hi, I am attempting to Add a DataRow to an empty DataTable. Using LINQ.
This is my LINQ query:
Dim q = (From d In Source.AsEnumerable()
Let fileName = d.Field(Of String)("a.input_extern_file_name")
Let ra_sys = d.Field(Of String)("a.ra_sys")
Let colName = d.Field(Of String)("ColumnName")
Let remarks = Reference.AsEnumerable().Where(Function(f) f.Field(Of String)("INPUT_FILENAME") = fileName).Count()
Select d)
For Each missingFile In q
Missing.Rows.Add(missingFile)
Next
For every row in the Source datatable I am taking the value from the “a.input_extern_file_name” column and Counting the number of times it occurs in the Reference datatable’s “INPUT_FILENAME” column and then the number if times it occurs is stored in the “Remarks” column of the Source datatable. And then I am trying to add the Row to the Missing datatable.
However I am getting this error:
RemoteException wrapping System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> RemoteException wrapping System.ArgumentException: This row already belongs to another table.
at System.Data.DataTable.InsertRow(DataRow row, Int64 proposedID, Int32 pos, Boolean fireEvent)
at UiPathCodeRunner_6fd11f9842d1403f9fc17b67fcc16d7a.Run(DataTable Reference, DataTable Source, DataTable& Missing)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at UiPath.Activities.System.Utilities.InvokeCode.CompilerRunner.Run(Object[] args)
at UiPath.Activities.System.Utilities.InvokeCode.NetCodeInvoker.Run(String userCode, List`1 inArgs, IEnumerable`1 imps, Object[] args)
at UiPath.Core.Activities.InvokeCode.Execute(CodeActivityContext context)
at System.Activities.CodeActivity.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)
.
Attached is my Workflow. Kindly assist. Thank you in advance.
Filter.xaml (12.4 KB)