From: Rolf M. <rm...@fa...> - 2008-04-07 16:02:41
|
When I try to convert the string to decimal using a >.< and the culture is non-US, I get a "string not in correct format" error. Code is: CultureInfo ci = CultureInfo.CurrentCulture; NumberFormatInfo nfi = ci.NumberFormat; decimal decPrice, decCost; string x = pricePieces[0].Replace(nfi.CurrencyDecimalSeparator, "."); decPrice = decimal.Parse(x); Because the non-US culture expects a >,< as the separator, it will not take the >.<. At one point (last week) I did get the data with a comma delimiter into the table, but don't remember how I did it... maybe make decPrice a string and let Firebird do the conversion? Also, can you point me to a doc that shows how to use parameters when building a query? I've always done it this way, not knowing whether it was right or wrong. Regards, Rolf Jiri Cincura wrote: > On 4/7/08, Rolf Marsh <rm...@fa...> wrote: > >> string fbInsertString = "insert into tBooks values ('" + >> BookNbr + "', '" + >> Title.ToString().Replace("'", "''") + "', '" + >> Author.ToString().Replace("'", "''") + "', '" + >> ISBN + "', '" + >> Illus + "', '" + // >> Locn + "', '" + >> decPrice + "', '" + >> decCost + "', '" + ... >> > > Use parameters(!), not composing query. Here you have 2 problems > (except composing). 1. You're placing >'< around number. 2. The FB > server is accepting only >.< as decimal separator so using >,< is > mistake (that's why you get the wrong number). > > |