我有一个存储程序。从此我想要输出值,但显示以下错误:
System.OverflowException:对于 Int32,值太大或太小。
我的店铺流程
ALTER proc dbo.[RECnoofDue]
@acno varchar(100),
@NoofDue numeric(18,2) output
as
Begin
select @NoofDue=isnull(SUM(Avgr),0) from (
select NoOfDue, LHEMI, TotalEMIDue, sunday, Avgr from
(SELECT COUNT(LHID) AS NoOfDue, LHEMI, SUM(LHEMI) AS TotalEMIDue,
SUM((Case when LHSundryBalance is null then 0 else LHSundryBalance end)) AS sunday,
((SUM(LHEMI)-SUM((Case when LHSundryBalance is null then 0 else LHSundryBalance end))) / LHEMI) AS Avgr
FROM dbo.TblLoanHistory WHERE (LHAcNo = @acno) AND
(LHEMIPaid = 0 OR LHEMIPaid IS NULL)AND (LHFileStatus IS NULL) GROUP BY LHSundryBalance, LHEMI,LHFileStatus ) x
union
(SELECT COUNT(LHID) AS NoOfDue, LHEMI, SUM(LHTotalOverDue) AS TotalEMIDue,
SUM((Case when LHSundryBalance is null then 0 else LHSundryBalance end)) AS sunday,
((SUM(LHTotalOverDue)-SUM((Case when LHSundryBalance is null then 0 else LHSundryBalance end))) / LHEMI) AS Avgr
FROM dbo.TblLoanHistory WHERE (LHAcNo = @acno) AND (LHEMIPaid = 0 OR LHEMIPaid IS NULL) AND
(LHFileStatus = 'BK')GROUP BY LHSundryBalance, LHEMI)) bb
end
我的 ASP.NET C# 代码
private double NOofDueCount()
{
using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["OptimaWebCustomerQueryCon"].ConnectionString))
using (SqlCommand cmd = new SqlCommand("dbo.RECnoofDue", conn))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@acno", SqlDbType.Int);
cmd.Parameters.Add("@NoofDue", SqlDbType.Int).Direction = ParameterDirection.Output;
cmd.Parameters["@acno"].Value = hfLoanAcNo.Value;
conn.Open();
cmd.ExecuteNonQuery();
using (SqlDataReader dr = cmd.ExecuteReader())
{
if (dr.Read())
{
return Convert.ToDouble(cmd.Parameters["@NoofDue"].Value);
//int contractID = Convert.ToInt32(cmd.Parameters["@NoofDue"].Value);
}
}
conn.Close();
return 0;
}
}