Excuse me, I want to try the result of output datatable (string type) convert to double type, because I want to put it in the if condition, but it occurs error…anyone know know how to solve it?
What is the variable res? Is it a single value, a row or the entire data table? If it is a single value try using convert.toDouble(res.toString)
. If it is a row, you will need to specify which column of the row you wish to convert. If it is a data table you will need to specify both the row and the column you wish to convert.
The res is that I use sql query “COUNT(*)” to count the amount of rows…I think it’s a single value, but I’ve tried convert.toDouble(res.toString) just now, but it doesn’t work😭
Ahh I see ok. Hmm interesting, what type of variable is res being stored as? Is it just a string or is it being stored as something else?
It’s a string
Oh I think I see the issue! You are assigning it back to the same variable, which is set as type string. You are trying to insert a double type into a string type. Try creating a new variable of type double and, using either of the formats, do the same assign but to the variable of type double.
OH YESSSS IT WORKED!!! FINALLY Thank you for your help and thanks for you patient You’re the most kind-hearted person I’ve ever met
No problem! Try writing the string res to console using a writeline/log activity before you try changing the variable to double and see what the string actually contains. Depending on that, you may need to trim it or if it contains other symbols besides numbers and a decimal point, use regex to extract the numerical value.
Oh! That would make sense. If you wanted only the number from that string you could do the following using regex:
This should return the number only and convert it to a double value (you don’t need to assign the default value in the variables, I only included that for testing)
If there are any other issues let me know!
Thank you sooooo much You solved it You’re so knowledgeable and brilliant
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.