[Mono-list] Converting float to string for a MySQL db and internationalisation

yoros@wanadoo.es yoros@wanadoo.es
Sat, 27 Dec 2003 08:59:13 +0100


On Fri, Dec 26, 2003 at 08:48:48PM +0100, Sergio Blanco Cuaresma wrote:
> 
> I have a little problem and I don't know how to solve it in an elegant
> way, due to internationalisation (my locales are "es_ES@euro") when I
> convert from a float type to string the decimal separator is ",", thats
> fantastic but I'm trying to insert that value in a MySQL database, and
> it seems to need "." as decimal separator:
> 
> string sql = "INSERT INTO indexed VALUES ('" +
> (fileInfo.Length).ToString("#.##") + "');";
> 
> How would you solve this little problem? Is there any more elegant way
> of inserting data in a MySQL database? I'm using ByteFX.Data.
> 

You can change DecimalSeparator to ".":

	using System.Globalization;
	...
	NumberFormatInfo.CurrentInfo.NumberDecimalSeparator = ".";

Regards,

    Pedro



-- 
Pedro Martínez Juliá
\  yoros@terra.es
)|    yoros@wanadoo.es
/        http://yoros.dyndns.org
Socio HispaLinux #311
Usuario Linux #275438 - http://counter.li.org
GnuPG public information:  pub  1024D/74F1D3AC
Key fingerprint = 8431 7B47 D2B4 5A46 5F8E  534F 588B E285 74F1 D3AC