我应该使用哪种数据类型的数字类型157838.6 [英] Which datatype should I use for those type of numbers 157838.6

查看:155
本文介绍了我应该使用哪种数据类型的数字类型157838.6的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,我有这个号码157838.6,并且我使用了很多数据类型但是当我尝试在与SQL数据库绑定的某个文本框中插入此数字时没有任何工作我出现此错误

(输入字符串的格式不正确。)



我尝试过:



尝试浮动,金钱,小数无效

hello, I have this number 157838.6, and I used many data type but nothing work when I try to insert this number in some text box bound with SQL database I have this error appear
(Input string was not in a correct format.)

What I have tried:

try float,money,decimal nothing worked

推荐答案





它不是很清除数据可能存在的问题。你说你已经尝试了浮点数,金钱和小数但没有任何效果,但是这些数值在这些数据类型的范围内,所以范围不是问题(即你不必点击并尝试所有数据类型,浮点数应该足以满足您的要求。)



问题可能是您所属地区的文化。

在某些地区,NumberDecimalSeparator是','而在其他地区,它是'。'。



您可以做的是验证它是哪一个。为此,您可以转到控制面板 - >语言和地区(W10上的语言) - >更改日期时间或数字格式 - >检查您的小数符号,如果需要,请更改它。

对于W10更改日期时间或数字格式 - >其他设置,你可以在这里查看。



如果格式有问题,最好的办法是在执行任何操作之前验证文本框中的输入在它上面。



谢谢,祝你好运。
Hi,

It is not very clear what might be the problem with your data. You say that you have tried float, money, and decimal but nothing works, but the value is well within the range of any of these data types, so the range is not the problem (i.e. you don't have to hit and try all the data types, float should be enough for your requirements).

The issue could be the culture of the region you belong to.
In some regions, the NumberDecimalSeparator is a ',' whereas in others it is a '.'.

What you can do is verify which one is it. For that, you can go to control panel -> Language and regions (Language on W10) -> Change date time or number formats -> Check your decimal symbol, change it if required.
For W10 Change date time or number formats -> Additional settings and you can check here.

If the format is the problem, your best bet would be validating the input from your text box before you perform any kind of operations on it.

Thanks and good luck.


你可以使用float.TryParse方法来解析文本框值。另外一个选项是使用NumericUpDown控件或maskedtextbox而不是文本框。
You can use float.TryParse method to parse the textbox value.Another option is to use NumericUpDown control or maskedtextbox instead of textbox.


这篇关于我应该使用哪种数据类型的数字类型157838.6的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆