如何将文本框值转换为十进制(4,4) [英] How to convert textbox value to decimal(4,4)

查看:91
本文介绍了如何将文本框值转换为十进制(4,4)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在将值存储在Decimal(4,4)类型的数据库中时遇到问题.在txtbox中输入值时,会引发异常将数据类型数字转换为十进制时出错".
请为我提供解决方案

I am facing problem to store a value in database of type Decimal(4,4). On entering the value in txtbox it throws an exception ''Error converting data type numeric to decimal.''
Please help me for solution

推荐答案

小数(4,4)表示总长度为4,其中4个保留为小数.那么小数点前将没有任何内容.


Ex Decimal(10,8)表示总长度10,其中十进制前为8,十进制后为2.

Decimal (4,4) means total length is 4, out of which 4 are reserved for decimal. Then nothing will be before decimal.


Ex Decimal(10,8) means total length 10 out of which 8 before decimal and 2 after decimal.


使用Round函数,在这种情况下,当第三个参数不为0时,它将截断而不是舍入
Use Round function, in this when third parameter is not 0, then it truncates rather than rounds
ROUND ( 123.456 , 2 , 1 )


您还可以参考
http://msdn.microsoft.com/en-us/library/ms175003(SQL .90).aspx [ ^ ]


Further you can refer
http://msdn.microsoft.com/en-us/library/ms175003(SQL.90).aspx[^]


这篇关于如何将文本框值转换为十进制(4,4)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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