In Spain the use of ',' and '.' is switched when writing currency values. e.g.:
$12,500.50 becomes $12.500,50
>UPDATE. So, I searched the project for ToDecimal and added CultureInfo.InvariantCulture to all the conversions. I'm going to do that for ToFloat and ToDouble as well now.
>
>
>Hi everybody,
>
>I have the following lines of code:
>
>else if (SqlDbType.Decimal == parameterType || SqlDbType.SmallMoney == parameterType)
> {
> if (parameterSize > 0)
> parameter = new SqlParameter("@" + parameterName, parameterType, parameterSize);
> else
> parameter = new SqlParameter("@" + parameterName, parameterType);
> parameter.Value = parameterValue.ToDecimal();
> }
>
>
>My parameterValue is a string
>
>-993.13
>
>When the last line is executed, I'm getting
>
>Parameter.Value = + SqlValue {-99313} object {System.Data.SqlTypes.SqlDecimal}
>
>Prior to executing that code I executed the following:
>
>
>CultureInfo.DefaultThreadCurrentCulture = culture;
> CultureInfo.DefaultThreadCurrentUICulture = culture;
>
> Thread.CurrentThread.CurrentCulture = culture;
> Thread.CurrentThread.CurrentUICulture = culture;
>
>and my culture was 'es'.
>
>So, apparently in es converting 993.13 to Decimal produced 99313 and the . was ignored.
>
>I need to treat it as normal decimal value. I'm going to research if ToDecimal allows specifying English culture and looks like we would need to be careful with all parsing and converting of the string values into decimal.
>
>Thanks a lot in advance.