以前和程序没有问题,现在老是出现这"连接都已被使用并已达到最大池大小"
错误提示
超时时间已到。在从池中获取连接之前超时时间已过。出现这种情况可能是因为所有池连接都已被使用并已达到最大池大小。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
以前是用的Sql句语,后来改成存储过程之后就出现在上面的这种情况.
代码如下:
SqlConnection cn = new SqlConnection(DbHelperSQL.connectionString);
if( cn.State == ConnectionState.Closed)
{
cn.Open();
}
SqlCommand cmd = new SqlCommand();
cmd.Connection = cn ;
cmd.CommandText = "Add_SaleSettleBill ";
cmd.CommandType = CommandType.StoredProcedure ;
SqlParameter parm = new SqlParameter( "@CompanyId ",SqlDbType.VarChar,20);
parm.Value = ssbm.CompanyId;
cmd.Parameters.Add(parm);
parm = new SqlParameter( "@BillNo ",SqlDbType.VarChar,20);
parm.Value = ssbm.BillNo ;
cmd.Parameters.Add(parm);
parm = new SqlParameter( "@CustId ",SqlDbType.VarChar,20);
parm.Value = ssbm.CustId ;
cmd.Parameters.Add(parm);
parm = new SqlParameter( "@Sales ",SqlDbType.VarChar,20);
parm.Value = ssbm.Sales ;
cmd.Parameters.Add(parm);
parm = new SqlParameter( "@doMan ",SqlDbType.VarChar,20);
parm.Value = ssbm.doMan ;
cmd.Parameters.Add(parm);
parm = new SqlParameter( "@PayBillNo ",SqlDbType.VarChar,20);
parm.Value = ssbm.PayBillNo ;
cmd.Parameters.Add(parm);
parm = new SqlParameter( "@ifDuct ",SqlDbType.Bit);
parm.Value = ssbm.ifDuct ;
cmd.Parameters.Add(parm);
parm = new SqlParameter( "@VoiceNo ",SqlDbType.VarChar,20);
parm.Value = ssbm.VoiceNo ;
cmd.Parameters.Add(parm);
parm = new SqlParameter( "@RealAmount ",SqlDbType.Float);
parm.Value = ssbm.RealAmount ;
cmd.Parameters.Add(parm);
parm = new SqlParameter( "@FeeAmount ",SqlDbType.Float);
parm.Value = ssbm.FeeAmount ;
cmd.Parameters.Add(parm);
parm = new SqlParameter( "@InstFeeAmount ",SqlDbType.Float);
parm.Value = ssbm.InstFeeAmount ;
cmd.Parameters.Add(parm);
parm = new SqlParameter( "@BalanceAmount ",SqlDbType.Float);
parm.Value = ssbm.BalanceAmount ;
cmd.Parameters.Add(parm);
parm = new SqlParameter( "@DepositRest ",SqlDbType.Float);
parm.Value = ssbm.DepositRest ;
cmd.Parameters.Add(parm);
parm = new SqlParameter( "@UseDeposit ",SqlDbType.Float);
parm.Value = ssbm.UseDeposit ;
cmd.Parameters.Add(parm);
parm = new SqlParameter( "@Result ",SqlDbType.VarChar,20);
parm.Direction = ParameterDirection.Output;
cmd.Parameters.Add(parm);
try
{
cmd.ExecuteNonQuery();
}
catch(