Value of type 'Integer' cannot be converted to 'System.Data.DataRow'

datatable
error
variable

#1

Hi Developers

I’m getting the error stated in the title (refer screenshot). My objective is to get the index number of each row in the data table and use that as a variable (Rowstart). This variable is then in the selector and is used to click through the same number of lines in SAP.

I just can’t seem to get around this error and have already searched everywhere for some ideas but haven’t found any.

Can anyone please help?

Thanks.

Sergio


#2

The index of is taking an invalid argument. It will work if you put it like that:
Range.Rows.IndexOf(row).Tostring

The IndexOf takes an entire row of the data table as an argument.


#3

Thanks Loginerror. That solved the problem. But now I have a new one.

Range.Rows.IndexOf(row).Tostring is reading the first value as 0 but I need the fist value to be 2 as the selector in SAP for the first row I need to click is 2.

I’m trying but not getting there. Tried doing an assign using CInt(Rowstart)+2 but it tells me that cannot assign from type ‘System.Int32’ to type ‘System.String’ in Assign activity ‘Assign’


#4

HI @Sergio_Goncalves,

Try below code
row(0).ToString()


#5

Simply add 2 within the assign activity, like this:
(Range.Rows.IndexOf(row)+2).ToString


#6

So Simple. Thanks Loginerror. I was missing the parenthesis. Solved.