Nick Name Generator Exercise from DataManipulation Lesson

Here, after retrieving rows from data table using select method . I tried to iterate through the rows using “for each” activity(since select method returns us array) to get the first column for which I had created “firstname” variable which is string type and have set the “Type Argument” of For each loop to “Datarow” as well but still m getting the error the error mentioned in the screenshot. Please provide me some solution!
NickNameGenerator|690x387

Hi,

The select statement you are using at the end of select statement use method copytodatattable and use for each row activity and you will be able to get the values.

Refer below example

ExtractedDataTable.Select("[Type]=‘WI5’ AND [Status]=‘Open’").CopyToDataTable and the output of this will be datatable

To get FirstName Column values inside for each use row(0).tostring

2 Likes

@Shruti_Shree - please go through it Loop through a data table

Hi @Shruti_Shree,

As your screenshot is not visible, I’m unable to understand the error message. Anyway, please change the type argument of 'for Each ’ loop to System.Data.Datarow instead of Datarow array and try again.

Warm regards,
Nimin

2 Likes

Hey Nimin,
Thanks for your reply! And, sorry for the screenshot. I am unable to upload here the screenshot image and the main.xaml as well . I am already using system.data.datarow but still stuck.

If you are done with the foundation course in ui path then you may refer to the data manipulation(Lesson 3) Practice 1(Nick Name Generator exercise)

Hi @Shruti_Shree,

Could you please provide some more details regarding the error? Kindly copy the error message and paste here.

Warm regards,
Nimin

Exercise:-

  1. I need to read a CSV file(contains First , Last column) and have to select method to retrieve certain rows based on a condition. - (The select will return us array - no error till here)
  2. Since I need to iterate through array so using “For Each” to extract “First” and “Last” from returned array and should add the first and last name. - (here while using for each loop,I have already set the Type Argument of “For each” to System.data.datarow and to extract “First” column from array, I am using assign activity where the “To” field is set a variable of string type and “Value” field of assign activity consists of row(“First”).ToString (this is where I am encountering the error)

The error says "Compiler error enountered while processing row(“First”).ToString , Options strict disallows implicit conversions from “String” to “Integer” .

Hi @Shruti_Shree,

Please check your variable panel and make sure that the variable you are trying to assign values of row(“First”).ToString and row(“Last”).ToString are of type “String”.

Warm regards,
Nimin

Hi Shruti,

I’m getting same error, are you manage to complete this exercise? @nimin Variable is already in String type and still have the same error