[Mono-devel-list] Re: Using floats with decimal comma from MS-SQL db (internationalisation)

Martin Honermeyer maze at strahlungsfrei.de
Mon Oct 4 11:01:18 EDT 2004

I just helped myself with the following bit of code, inside the main loop (through all rows):

if(row.RowState == DataRowState.Modified) {
 row["Vorauszahlung"] = Double.Parse(row["Vorauszahlung"].ToString()).ToString().Replace(",", ".");
 row["Gutschrift"] = Double.Parse(row["Gutschrift"].ToString()).ToString().Replace(",", ".");

Every double or money field in the query has to be converted here.. This is really awkward!


Martin Honermeyer wrote:

> Hello,
> there is a big problem with using Float or Money values with DataSets and
> SqlClient on MS-SQL Server.
> I am doing a query from a table with Money values. Those are returned with
> decimal comma, as we are having a localized German database. Using a
> DataSet with a DataReader and a prepared update command, updating fails.
> This is because the comma is recognized as a separator between different
> fields.
> I worked around this by changing the NumberFormatInfo of the Culture in
> the current thread. This works as long as the float fields are changed
> (rewritten) before the adapter.Update().
> If not all float fields are changed in between, the update fails again,
> because the update statement is filled with the original field values,
> with contain the decimal comma.
> To cut a long story short, in my opinion this is a real shortcoming,
> supposedly in the TDS client code. From my point of view, it doesn't seem
> to convert float and money values correctly! This is really bad behaviour
> and I won't be able to get my program any further without a fix..
> Appreciating any help!
> Greetz,
> Martin

More information about the Mono-devel-list mailing list