Hi, @jack.chan
I have datarow variable called drCommon and I am assigning it a value froom the Datable Output_DB as
(cmnString is a variable of String Type which holds the value 25)
While doing this I am getting an Error as :
Can anyone suggest me something on this ?
johnfelix
(John Felix Yesuraj)
September 26, 2022, 10:33am
2
Hi @Ishan_Shelke
The error message you should get is below, because datatable.select() always returns array of data row. which you cannot assign to a data row variable.
But you got different error message. could you please check the variable data type of drCommon and Ouput_DB
You should use row index position to assign
Output_DB.Select(cmnString).ElementAt(rowIndx )
(cmnString is a variable of String Type which holds the value 25)
Your select query format is wrong, it should have column name in the query, operator and the filter value.
Please refer to this post for filtering data table
Four Ways to Filter Data Tables in UiPath Studio | UiPath
Thanks
John
Sanjit_Pal
(Sanjit Pal)
September 26, 2022, 10:35am
4
Hello @Ishan_Shelke ,
You are trying to assign collection of rows to a row type variable, which is not possible. Use the method suggested by @johnfelix
Thanks,
Sanjit
Here as far as I can see the variable type is Array of Datarow which should eventually work
Output_DB is a datatable type of variable
Past 1 month, this was working fine this error popped up today
Okay, as per your suggesstion I modified the following cmnString variable to but it’s still not working
johnfelix
(John Felix Yesuraj)
September 26, 2022, 10:48am
6
Your error message, code and the screenshot does not sync logically.
So not sure why this error message appearing now.
Have you recently updated any package versions? if so, then please downgrade packages to older version and try again.
johnfelix
(John Felix Yesuraj)
September 26, 2022, 10:55am
7
Hi @Ishan_Shelke
You code should look like below
Output_DB.Select(“[Dealer Code] ='”+row(0).ToString.Trim+“'”)
Please check row(0).ToString.Trim has value in it.
Ok I’ll try to Explain More Clearly
I have a excel file named A which has columns named Dealer Code, Dealer Name, and City and I am reading it with a read range and storing into a datable called Output_DB
I have another Excel file named B which also contains the Column Dealer Code, Dealer Name and City.
What I am trying to do is, If the dealer Code in sheet B is also present in the sheet A then I am picking the Whole Row of Sheet A and storing it into a Datable
To pick the Dealer Code of Sheet B I am using the Following Code Snippet.
and to search for the Rows in the Sheet A I am trying to use the following code snippet
Doing so I am getting the above following Error mentioned in my First post
jack.chan
(Jack Chan)
September 27, 2022, 3:57am
9
@Ishan_Shelke
change Output_DB.Select(cmnString)
to
Output_DB.Select(cmnString)(0)
because Select function returns array of datarows whereas drCommon is a single datarow variable
johnfelix
(John Felix Yesuraj)
September 27, 2022, 6:40am
10
Hi @Ishan_Shelke
I am unable to figure out the issue.
Our previously discussed solutions should work but, in your case, it’s not working
Excel A / Sheet A - Output_DB
Excel B / Sheet B - dt_Sheet_B
So here is the different approach to get same results
Approach 1 - Using Merge data table
Excel_Data_Filter_Approach_1.xaml (18.8 KB)
Approach 2 - Using Filter data table
out_dt_Output
Excel_Data_Filter_Approach_2.xaml (18.8 KB)
Points to note:
Used clone method to copy the header from Output_DB to dt_Temp
Used dt_Temp to store filtered rows from Output_DB
These two approaches have output in data table data type instead of data row / array of data row data type
Output Data Table activity is used for debugging purpose and not applicable to your requirement
Please let us know if you are still facing the error.
Thanks
John
system
(system)
Closed
September 30, 2022, 6:40am
11
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.