现在的位置: 首页 > 综合 > 正文

每天都有新发现 2009年10月21日 Decimal 和存储过程OUTPUT

2013年07月14日 ⁄ 综合 ⁄ 共 912字 ⁄ 字号 评论关闭

decimal(C# 参考)

decimal 关键字表示 128 位数据类型。同浮点型相比,decimal 类型具有更高的精度和更小的范围,这使它适合于财务和货币计算。decimal 类型的大致范围和精度如下表所示。

大致范围:±1.0 × 10-28 到 ±7.9 × 1028

精度:28 到 29 位有效位

.NET Framework 类型:System.Decimal

如果希望实数被视为 decimal 类型,请使用后缀 m 或 M

 

存储过程中返回值 OutPut的使用举例!

在c#代码中的调用。

        public string GetInpourTrackCumulativeResult()
        {
            using (SqlConnection connection = GetSqlConnection())
            {
                SqlCommand command = new SqlCommand("InpourTrack_GetCumulativeResult", connection);
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("@ReturnCumulativeResult",SqlDbType.Decimal).Direction =ParameterDirection.Output;
                
                connection.Open();
                command.ExecuteNonQuery();


                string CumulativeResult = command.Parameters["@ReturnCumulativeResult"].Value.ToString();
                connection.Close();
                return CumulativeResult;
            }
        }

数据库中存储过程:

CREATE PROCEDURE [dbo].[InpourTrack_GetCumulativeResult]
	@ReturnCumulativeResult Decimal OUTPUT
AS
BEGIN
	
	SET NOCOUNT ON;

    set @ReturnCumulativeResult=( SELECT SUM(AccountNO) FROM InpourTrack)

END
 

抱歉!评论已关闭.