List:MySQL and .NET« Previous MessageNext Message »
From:Jordan Sparks Date:February 11 2005 2:30pm
Subject:RE: Decimal point being changed ot decimal Comma by MySqlComman:Command text
View as plain text  
You're talking to yourself.

Here's how I send all my dateTime values to MySQL:
return myDateT.ToString("yyyy-MM-dd
HH:mm:ss",CultureInfo.InvariantCulture);

Otherwise the year gets altered in the Korean culture because they use a
different year calendar.

As you can see, it's in a separate function.  Every value that goes out
to the database gets routed through a similar function.  The one for
strings handles all the quotes, etc.  I don't even think about sending
data directly to the database anymore except maybe an int.ToString()
which I haven't found any problems with.  Same for data coming in from
db, although less of an issue.


Jordan Sparks
 

-----Original Message-----
From: Guy Platt [mailto:guy.platt@stripped] 
Sent: Friday, February 11, 2005 3:47 AM
To: Guy Platt
Cc: dotnet@stripped
Subject: Re: Decimal point being changed ot decimal Comma by
MySqlComman:Command 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