负数值的数据类型 [英] Datatype for Negative numeric values

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

问题描述

大家好,

我有一张表,需要在其中一列中存储-562,000.00之类的值.我已经声明该列的字段类型为numeric(18,2).我正在尝试使用存储过程来更新这些列,但是当我从代码中将参数添加到命令对象中时,为

HI All,

i have a table which needs to store values like -562,000.00 in one of its columns. i have declared the field type to be numeric(18,2) for that column. I am trying to update that columns using a Stored Procedure but wheni add parameters to the command object from code as

comm1.Parameters.Add("@Excl", SqlDbType.Decimal).Value = Convert.ToDecimal(objDataSet.Tables[0].Rows[i]["Excl"]);


我遇到错误.

我应该在这里使用什么数据类型?

谢谢.


I am getting an error.

What is the Datatype i should be using here?

Thanks.

推荐答案

使用单行将有效.

Use single it will work

comm1.Parameters.Add("@Excl",  SqlDbType.Decimal).Value = Convert.Single(objDataSet.Tables[0].Rows[i]["Excl"]);







or

comm1.Parameters.Add("@Excl",  SqlDbType.Float).Value = Convert.Single(objDataSet.Tables[0].Rows[i]["Excl"]);


这篇关于负数值的数据类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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