List:MySQL and .NET« Previous MessageNext Message »
From:Guy Platt Date:February 11 2005 11:47am
Subject:Re: Decimal point being changed ot decimal Comma by MySqlComman:Command
text
View as plain text  
For those interested, the problem can be fixed by using 
"CultureInfo.InvariantCulture" to stop the decimal being replaced with a 
comma.

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

Guy Platt said the following wise words on 2005-02-11 12:21:

> Hi,
>
> 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 ) / 
> fundValue));
> fundShare = Math.Round(fundShare,2);
>
> myCmd.CommandText = "INSERT INTO performance_detail (FundNr, 
> FundShare) VALUES ('"+ fundNr +"','"+ fundShare +"')";
> myCmd.ExecuteNonQuery();
>
> 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?
>
> thanks
>  Guy
>
>
>

Thread
InnoDB errornil189 Feb
  • Re: InnoDB errorJorge Bastos9 Feb
    • Re: InnoDB errorSGreen9 Feb
      • Re: InnoDB errorJorge Bastos11 Feb
        • Decimal point being changed ot decimal Comma by MySqlComman:CommandtextGuy Platt11 Feb
          • Re: Decimal point being changed ot decimal Comma by MySqlComman:CommandtextGuy Platt11 Feb
            • RE: Decimal point being changed ot decimal Comma by MySqlComman:Command textJordan Sparks11 Feb
              • RE: Decimal point being changed ot decimal Comma by MySqlComman:Command textReggie Burnett23 Feb
                • Ann: MyGeneration supports MySQL through the MySQL Connector/Net providermike.griffin23 Feb
                  • RE: MyGeneration supports MySQL through the MySQL Connector/Net providerReggie Burnett23 Feb
Re: InnoDB errorSGreen9 Feb