同样的文化,不同的价值转换 [英] Same Culture, different value conversions
问题描述
我的网站提取从一个文本文件数据到数据库中。读取数据后,我转换字符串值转换为双,使用:
My website extracts data from a text-file into a database. After reading the data, I convert string-values into double, using:
oracom.Parameters.Add("nstpreisvm", OracleDbType.Double).Value = Convert.ToDouble(_material.Mat_StPreisVm);
如果我现在检查结果在数据库中,(列期望 NUMBER
-format),我得到两个不同的值:通过Visual Studio 2010中在我的本地,数据库返回 10,15
- 但是,如果我做的web服务器的过程中,数据库只能说明 10
。这是如何发生的?
If I check the results in the database now, (The column expects the NUMBER
-format), I get two different values: On my localhost via Visual Studio 2010, the database returns 10,15
- But if I make the process on the webserver, the database only shows 10
. How does this happen?
我现在实现了网站上的小标贴,与当前文化的页面加载加油吧:
I implemented a little lable on the website now, filling it with the current culture on the Page-Load:
label.Text = Thread.CurrentThread.CurrentCulture.ToString();
的的CurrentCulture
是 EN-GB
的两个实例,所以这里有什么问题吗?我缺少什么?
The CurrentCulture
is en-GB
for both instances, so what is the problem here? Am I missing anything?
我的本地Windows是Win7的SP1与德国语言包,服务器的Win2008 R2使用标准英语安装。
My local windows is Win7 SP1 with a german language-pack, the server is Win2008 R2 with standard English installation.
推荐答案
我们有一个客户服务器凡客已经手动更改小数点分隔符为服务器上的特定文化上类似的问题。您可以检查此使用:
We had a similar problem on a customer server where the customer had manually changed the decimal separator symbol for a particular culture on that server. You can check this using:
Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator
我会建议明确指定小数点分隔符,当你做解析:
I would suggest explicitly specifying the decimal separator symbol when you do the parsing:
Double.Parse("1,25", new NumberFormatInfo(){ NumberDecimalSeparator = "," });
这篇关于同样的文化,不同的价值转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!