Uipath and Database Connection

Hello guys,

I have come up with another problem.

Book1.xlsx (8.6 KB)

I have attached an excel file. In this excel file suppose I have stored “Ramesh” under column name “Name”.

My question is how to fetch “Ruskin” under column name “Name” and “Manager” under column name “Designation” using database and uipath connection or any other logic.

The logic should be dynamic since the stored value (“Ramesh”) can change .

Can you please help me??

Thanks & Regards
Nirmalya

1 Like

Hey @nirmalya.sarkar

You will be reading this data from an Excel or DB and storing the same in a DataTable

The below method helps in fetching the Designation using Column Headers from the DataTable

dt_Data.AsEnumerable.Where(Function(row) row("Name").ToString.Equals(str_InputDynamicName)).First().Item("Designation").ToString

The below method helps in fetching the Designation using Column Position Index from the DataTable

dt_Data.AsEnumerable.Where(Function(row) row(0).ToString.Equals(str_InputDynamicName)).First().Item(1).ToString

Hope this helps

Thanks
#nK

Hi

Whether it is a database or excel, however it is the final variable is going to be a DATATABLE

When you know a value in one column of that datatable and if you want to get the corresponding value in another column then we can use LOOKUP DATATABLE activity

Have a view on this doc on how to use that activity

Cheers @nirmalya.sarkar

Hi @Nithinkrishna ,

image

After executing the logic it is showing this error.
image

Can you tell me why am I getting this error?

Regards,
Nirmalya

1 Like

Hey @nirmalya.sarkar

The filter logic doesn’t return any matching rows…

So better to add an if block first and then the logic if condition is true…

Below is the condition for IF

dt_Data.AsEnumerable.Where(Function(row) row("Name").ToString.Equals(str_InputDynamicName)).Count > 0

Thanks
#nK

Hi @Nithinkrishna ,

I have added this if condition(check with both if and while). But when the if block is true , it is going in “Then” block .

After that if/while block isn’t executed. It then check with next value which lead to “else” block.

Can you tell me where I have to add the if block ??

Regards,
Nirmalya

1 Like

@Palaniyappan ,

This video is quite similar to my query.

But my actual question is how to find the next value in “Designation” column as well as column name “Name”

Can you please guide me??

Regards,
Nirmalya

Hey @nirmalya.sarkar

Sorry, I’m not getting your point

You need to get the Designation of the row matched with the Name column or the Designation of the next row after finding the matched row with Name column.

Thanks
#nK