Studio Question on Query

Hi,
This is Studio question.
I have read an Excel into a datatable.
Added Assign activity with value OutputDT.Select(“Price>20”)
It shows an error for String to Int conversion.
I understand that the Price in datatable is in String format. How do I convert Price into integer in the query ? CInt does not work.

Thank you.

Hi

Try ,

OutputDT.select("Price=‘20’ ")

In Case if you have to pass the variable ,

OutputDT.select(“Price=’”+Variable.tostring+"’")

HAPPY AUTOMATION !!!

@Krishna_547 thank you. I see you made it string ("Price=‘20’). Can this be used to get all the items where price is greater than 20. Shouldn’t it be an integer ?

Hi ,

If it is with integer , try using Filter Data table activity with condition as shown below

image

@Krishna_547 I’m trying to use LINQ so want to avoid as much activity as possible.

@Prinal_C , i have suggested a simple one but anyway here is your solution in LINQ

OutputDT.AsEnumerable.Where(Function(r) CInt(r(“Price”).ToString) > 20).CopyToDataTable

1 Like

Hi @Prinal_C

Hope this would help you resolve this

OutputDT = OutputDT.AsEnumerable().Where(Function(a) Convert.ToInt32(a.Field(of string)(“Price”))>20).CopyToDataTable

Cheers

1 Like

Thank you @Palaniyappan and @Krishna_547 … it worked.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.