1

I have Textbox which takes decimal values. I have written Keypress event to enter decimal numbers. But when I am trying to convert the value in the textbox to Decimal format to store in database, it is only converting it to Integer.

I am trying to convert text to decimal as follows:

dr["Total Amount"] = Decimal.Parse(txtTotalAmount.Text.ToString());

well I am using the above code with the datagridview.

4

1 回答 1

1

请检查您表DataType中的总金额。如果您使用 SQL Server 并且想要存储十进制值,那么您必须根据需要使用货币十进制
注意:DECIMAL(2,2)DECIMAL(2,4)是不同的数据类型。这意味着 11.22 和 11.2222

于 2013-01-25T05:50:21.290 回答