Setting a variable from a query dataset


#1

Just learning UIPath and trying to set a variable based off a data set from a query. Currently set up as:

Execute Query: “SELECT * FROM tblSKUListingFiles WHERE LastUpdate <> date()”
Output-Datatable VendorList
VendorList is a variable set as Datatable to Main Scope
For Each:
Foreach item in “VendorList”
A-B Assign VNbr = VendorList.Select(“VNbr”)
Vnbr is a variable set to Int32 Scope Main.
This is where I get my compile error. It says it cannot assign from type 'System.Data.Datarow[] to type System.Int32 in Assign Activity ‘Assign’.

This is where I’m trying to set the variable VNbr to be whatever the item is in the query for that row. The ForEach will loop through so I need to change that variable each time.

Thanks for any and all help.


#2

HI @RichTHD,

i think inside for each you are assigning wrongly

Assign VNbr=item("VNbr")
image

Regards,
Arivu


#3

Hi, Arivu.
I switched the Foreach to row and created the variable for it as a string. It changed the error to “Option Strict On disallows late binding.” I believe I’m in the 2016 version if that makes a difference.


#4

can you share your xaml file or screenshot
@RichTHD,

Regards,
Arivu


#5

Main.xaml (32.4 KB)

I’m really new to this whole process so please forgive layout or how/why it’s set up how it is.


#6

int that VendorList data table which column are you checking for VType


#7

It’s the third column. item(2) since I know it starts at 0 like recordsets in Access.


#8

HI @RichTHD,
Refer this one.

Main (16).xaml (32.9 KB)

Regards,
Arivu


#9

Thank you, Arivu. I’ll spend some time comparing and adjusting.


#10

I see that you switched my VNbr to the VType. I was assigning the VNbr variable for the queries that are in the Switch under the 2 cases. I need to update information based off that VNbr depending on what the Vtype is at the switch. That’s why my assign is how it was. I tried updating to what you had and switched the spot from 2 to 1 but it’s giving me the late binding error again.