UpdateSpecificRow.xaml (6.0 KB)
I am encountering an error at this activity:Assign(1)
Where I assign the variable:
OneRowFromDataTable a DataRow object:
The error I receive: Assign(1): Cannot perform '=' operation on System.String and System.Int64.
I don’t understand is why am I encountering this error when there is no datatype of String or Integer involved in the assign activity.
Kindly assist. Thank you.
Okay, done. I now have a new problem, it is the second activity.
Where I assign
OneRowFromDataTable(0) = “Lolol”
The error I am getting is
Source: Assign(2)
Message: Cannot create an L-value from the given expression with property 'set_Item' because the target object is null.
Exception Type: System.NullReferenceException
System.NullReferenceException: Cannot create an L-value from the given expression with property 'set_Item' because the target object is null. at System.Activities.ExpressionUtilities.IndexerLocationFactory`1.IndexerLocation.set_Value(T value)
at System.Activities.Location`1.ReferenceLocation.set_Value(T value)
Based on my understanding OneRowFromDataTable is must be a datatable variable. If it is you have to enter your vb expression like this OneRowFromDataTable.Rows(0).Item("Column name you want modify / column index) = “Lolol”
For example I have a datatable called DT and it has 2 rows
Emp Name Age Salary Company Code
01 Robi 23 10000. 1
02 Navi 25 25630 4
If I need to update the first row in the salary column means. I have to enter below expression on my code DT.Rows(0).Item(“Salary”) = “20000”
After updation My datatable will look like
Emp Name Age Salary Company Code
01 Robi 23 20000 1
02 Navi 25 25630 4
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentException: Column 'ORDER_STATUS' does not belong to table DataTable. at System.Data.DataRow.GetDataColumn(String columnName)
at System.Data.DataRow.get_Item(String columnName)
at UiPathCodeRunner_365675f5c1ae40b6a5aa5e93ed4438a7._Closure$__._Lambda$__0-0(DataRow row)
However when I checked the Excel spreadsheet that, the Column ‘ORDER_STATUS’ does exist in the Excel and therefore it should exist in the DataTable that it had been read into. UpdateSpecificRow_2.xaml (7.1 KB)
I made a small modification to your LINQ statement, min looks like this:
io_dt.AsEnumerable.ToList.ForEach(Sub(row)
row("ORDER_STATUS") = If(row("Order_Num").ToString.Equals("1-48676792953"),"Updated Name",row("ORDER_STATUS").ToString)
End Sub)
Thanks, I have tried it on my own. I made a small modification to your LINQ statement, mine looks like this:
io_dt.AsEnumerable.ToList.ForEach(Sub(row)
row("ORDER_STATUS") = If(row("Order_Num").ToString.Equals("1-48676792953"),"Updated Name",row("ORDER_STATUS").ToString)
End Sub)
[UpdateSpecificRow_2.xaml|attachment](upload://f4fb9ggpoE2yHmQDR1pEdj0XFcv.xaml) (7.1 KB)
However, when I ran it, I got this error System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentException: Column 'ORDER_STATUS' does not belong to table DataTable. at System.Data.DataRow.GetDataColumn(String columnName) at System.Data.DataRow.get_Item(String columnName) at UiPathCodeRunner_365675f5c1ae40b6a5aa5e93ed4438a7._Closure$__._Lambda$__0-0(DataRow row)
This is my LINQ statement: