-1

アイスランドの運用データベース (SQL Server 2008R2) は、sqlmoney 列の値を小数点としてカンマ (,) で格納します (例 54,12 & 85,00)。私たちのアプリケーション (C#、ASP.Net) は、コードとして SqlDatareader を使用して値を読み取ります。

decimal testVal=dr.GetDecimal(idxAmountUSD)//IdxAmountUSD is sqlmoney value

コンマ (,) を小数点として考慮せず、5412 & 8500 として返すようになりました。

実際には、54.12 & 85.12 として返されるはずです。

4

2 に答える 2

0

SQLDataReaderのインスタンスを作成する前に、カルチャを定義する必要があります。

Application.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture("yourCulture");
于 2012-08-13T07:38:47.883 に答える
-2

You need to read the data culture specific, define the culture first and then read the data

Thread.CurrentThread.CurrentCulture = new CultureInfo("is-IS"); //is-IS is an iceland culture (where , is used inplace of .) .
// following line remains same
decimal testVal=dr.GetDecimal(idxAmountUSD)//IdxAmountUSD is sqlmoney value

I did not test the above code, but logically it is correct.

于 2012-08-13T07:52:56.020 に答える