Have a look at the definition for
Double.TryParse Method (System) | Microsoft Docs[
^] .
The
TryParse
method returns a boolean indicating if parsing was successful or not. The actual parsed value is returned using the second,
out
parameter.
So instead of using the return value from
TryParse
, you should have something like the example below.
Also note that the
AddWithValue
method has the value as second parameter so you should use that instead of the value property of the created parameter. Now you're passing the type as value. For more info, please see
SqlParameterCollection.AddWithValue(String, Object) Method (System.Data.SqlClient) | Microsoft Docs[
^]
if (!double.TryParse(productPrice, out double convertedPrice)) {
}
if (!double.TryParse(productSelPrice, out double convertedSelPrice)) {
}
cmd.Parameters.AddWithValue("@PPrice", convertedPrice;
cmd.Parameters.AddWithValue("@PSelPrice", convertedSelPrice);