For those interested, the problem can be fixed by using
"CultureInfo.InvariantCulture" to stop the decimal being replaced with a
So the command to create the CommanText becomes:
myCmd.CommandText = "INSERT INTO ppmr_performance_detail (FundNr,
FundShare) VALUES ('" + fundNr +"','" +
fundShare.ToString(CultureInfo.InvariantCulture) + " ' )";
regards to all,
Guy Platt said the following wise words on 2005-02-11 12:21:
> I'm running 1.0.4 and have encountered something strange.
> The following code crashes on the ExecuteQuery with a SQL error.
> fundShare = Convert.ToDecimal(( (allocationPerc / 100) * oldSum ) /
> fundShare = Math.Round(fundShare,2);
> myCmd.CommandText = "INSERT INTO performance_detail (FundNr,
> FundShare) VALUES ('"+ fundNr +"','"+ fundShare +"')";
> Checking under debug fundShare contains the value "95.66" but the
> CommandText shows this value as "95,66". I presume that it is a case
> of .NET storing the decimal with a placeholder or a decimal point, but
> when it is given to the CommandText the value is converted to show a
> decimal comma (which causes MySql to crash).
> Can anyone tell me how to overcome this?