Unable to cast object of type ‘System.Double’ to type ‘System.String’

Hi all,

I am getting error “Unable to cast object of type ‘System.Double’ to type ‘System.String’”
when I am using.
dtAlsExcel_In.Rows(dtAlsExcel_In.AsEnumerable().Where(Function(x) x.Field(Of String)(5)=trim(row(5).ToString)).Select(Function(x) dtAlsExcel_In.Rows.IndexOf(x)).FirstOrDefault())(16)

Please help.ALS Output File.xlsx (17.6 KB) Order Enquiry - Multiple Order Numbers _RPA (5).xlsx (29.0 KB)

Hi, the error is because you are using a variable of string type to handle Double value
To handle this error
Please create variable with generic type
And use variable.tostring wherever you are using it

What is the data type of variable in the left side of assign activity
Add .ToString atlast to this expression

Cheers @ravi.g6

Not working showing error “cannot assign from type system.object to uipath.core.genericValue”

Did this method helped work upon this
@ravi.g6

@palaniyappan
I am copying value from one data table to other the left side variable is also a expression.
To - dtAlsExcel_In.Rows(dtAlsExcel_In.AsEnumerable().Where(Function(x) x.Field(Of String)(5)=trim(row(5).ToString)).Select(Function(x) dtAlsExcel_In.Rows.IndexOf(x)).FirstOrDefault())(16)

From - dtOrderEnqSheet.Rows(dtOrderEnqSheet.AsEnumerable().Where(Function(x) x.Field(Of String)(0)=trim(row(5).ToString)).Select(Function(x) dtOrderEnqSheet.Rows.IndexOf(x)).FirstOrDefault())(21).ToString

Usually the left side should be a variable to hold the value in right side in a assign activity
Unless it’s a condition operation been used we should not use two expression in either sides
@ravi.g6

@Palaniyappan
Agreed but I have used these expression earlier and it has worked too.

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