int Result,i;
        Decimal  d_report_other_should_pay_fee = 0;
        using (SqlConnection connection = new SqlConnection(connectionString))
        {
            SqlCommand com = new SqlCommand("sp_maintain_multipurpose_cheque_add", connection);
            com.CommandType = CommandType.StoredProcedure;
            SqlParameter p1 = com.Parameters.Add("@report_date", SqlDbType.VarChar, 20);
            p1.Value = ReportDate.Text;
            SqlParameter p2 = com.Parameters.Add("@area", SqlDbType.VarChar, 20);
            p2.Value = Session["area_code"].ToString();
            SqlParameter p3 = com.Parameters.Add("@exchange_site", SqlDbType.VarChar, 30);
            p3.Value = ExchangeSite.Text;
            SqlParameter p4 = com.Parameters.Add("@bill_telecomm_id", SqlDbType.Decimal, 38);
            p4.Value = TELECOMM_ID.Text;
            SqlParameter p5 = com.Parameters.Add("@new_borrow_money_use", SqlDbType.Decimal, 30);
            p5.Value = Fee.Text;
            SqlParameter p6 = com.Parameters.Add("@memo", SqlDbType.VarChar, 250);
            p6.Value = Memo.Text;
            SqlParameter p7 = com.Parameters.Add("@enter_employee", SqlDbType.VarChar, 30);
            p7.Value = Session["UserID"].ToString();
            
            p1.Direction = ParameterDirection.Input;
            p2.Direction = ParameterDirection.Input;
            p3.Direction = ParameterDirection.Input;
            p4.Direction = ParameterDirection.Input;
            p5.Direction = ParameterDirection.Input;
            p6.Direction = ParameterDirection.Input;
            p7.Direction = ParameterDirection.Input;            SqlParameter p8 = com.Parameters.Add("@report_other_should_pay_fee", SqlDbType.Decimal,10);
            p8.Direction = ParameterDirection.Output;            SqlParameter p_out = com.Parameters.Add("@RETURN_VALUE", SqlDbType.Int, 1);
            p_out.Direction = ParameterDirection.ReturnValue;
            connection.Open();
             com.CommandTimeout = 3000;
            com.ExecuteReader();
            d_report_other_should_pay_fee = Convert.ToDecimal(com.Parameters["@report_other_should_pay_fee"].Value);
            Result = (int)com.Parameters["@RETURN_VALUE"].Value;
 
        }
存储过程测试,输出参数值含小数没问题

解决方案 »

  1.   

    存储过程如下CREATE  procedure [dbo].[sp_maintain_multipurpose_cheque_add]
    @report_date varchar(20),
    @area varchar(10),
    @exchange_site varchar(30),
    @bill_telecomm_id decimal(38),
    @new_borrow_money_use decimal(10,2),
    @memo varchar(250) ,
    @enter_employee varchar(20),
    @report_other_should_pay_fee decimal(10,2) output

    as
    begin
    declare 
    @telecomm_account varchar(20),
    @customer_name varchar(60),
    @bank varchar(20),
    @customer_account varchar(20),
    @borrow_money decimal(10,2),
    @borrow_money_use decimal(10,2),
    @label int
    select @label=0
    begin tran
     

    SELECT @telecomm_account=telecomm_account,@customer_name=customer_name,@bank=bank,@customer_account=customer_account,@borrow_money=borrow_money,@borrow_money_use=isnull(borrow_money_use,0)  from bill_telecomm where id=@bill_telecomm_id
    if (@borrow_money<=@borrow_money_use)
    begin
    print '警告:该支票费用已经使用完';
    rollback   tran  ; 
    select @report_other_should_pay_fee=0
    return -1;
    --select @label=-1;
    end
    if (@new_borrow_money_use>(@borrow_money-@borrow_money_use))
    begin 
    print '警告:支票费用使用费用大于剩余可用金额';
    rollback   tran   
    select @report_other_should_pay_fee=0
    return -2;
    --select @label=-2;
    end

    if (@borrow_money_use=0)
    select @report_other_should_pay_fee=@borrow_money-@new_borrow_money_use;
    else
    select @report_other_should_pay_fee=@new_borrow_money_use*(-1);
    print @report_other_should_pay_fee;
    insert into bill_telecomm_multipurpose_cheque(report_date,area,exchange_site,bill_telecomm_id, telecomm_account,customer_name,bank,customer_account,borrow_money,borrow_money_use,report_other_should_pay_fee,memo,enter_datetime,enter_employee )
     values(@report_date,@area,@exchange_site,@bill_telecomm_id,@telecomm_account,@customer_name,@bank,@customer_account,@borrow_money,@new_borrow_money_use,@report_other_should_pay_fee,@memo,GETDATE(),@enter_employee )
     
    update  bill_telecomm set borrow_money_use=@borrow_money_use+@new_borrow_money_use where id=@bill_telecomm_id

     
       

    commit tran ;

    --return @label ;
    return 0 ;
    end
      

  2.   

    CONVERT(varchar(20),CONVERT(numeric(10,2),@_ExpMoney))转换函数               Convert(numeric(总共位数,小数位数,___))
      

  3.   

       p8.Precision = (byte)10;
                p8.Scale = (byte)2; 
    请教了一位高手,加上这两句,就好了
      

  4.   

    SqlParameter.Precision
    SqlParameter.Scale
    没用过,我一般是传入或者是传出来之后在限制精度的。