超时时间已到,但是尚未从池中获取链接。求解!

criuslee 2014-12-15 09:00:36
private void button6_Click(object sender, EventArgs e)
{
int a = dgvAreaInfo.Rows.Count;
for (int b = 0; b < a; b++)
{
//获取内部工票价格
try
{
SqlDataReader sqlread = boperate.getread("SELECT sum(gpjg) as gpjg FROM tb_gpdd where '" + riqistart.Text.Trim() + "' <= ccrq and ccrq <= '" + riqiend.Text.Trim() + "' and cph='" + Convert.ToString(dgvAreaInfo.Rows[b].Cells[0].Value).Trim() + "' and jsfs = '内部用车' ");
if (sqlread.Read())
{
string zhi1 = sqlread["gpjg"].ToString();
this.dgvAreaInfo.Rows[b].Cells[5].Value = zhi1.ToString();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
}

//获取内部客车补助
try
{
SqlDataReader sqlread = boperate.getread("SELECT sum(kcbz) as kcbz FROM tb_gpdd where '" + riqistart.Text.Trim() + "' <= ccrq and ccrq <= '" + riqiend.Text.Trim() + "' and cph='" + Convert.ToString(dgvAreaInfo.Rows[b].Cells[0].Value).Trim() + "' and jsfs = '内部用车' ");
if (sqlread.Read())
{
string zhi2 = sqlread["kcbz"].ToString();
this.dgvAreaInfo.Rows[b].Cells[6].Value = zhi2.ToString();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
}

//获取内部货车补助
try
{
SqlDataReader sqlread = boperate.getread("SELECT sum(buzhu) as buzhu FROM tb_gpdd where '" + riqistart.Text.Trim() + "' <= ccrq and ccrq <= '" + riqiend.Text.Trim() + "' and cph='" + Convert.ToString(dgvAreaInfo.Rows[b].Cells[0].Value).Trim() + "' and jsfs = '内部用车' ");
if (sqlread.Read())
{
string zhi3 = sqlread["buzhu"].ToString();
this.dgvAreaInfo.Rows[b].Cells[7].Value = zhi3.ToString();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
}

//获取内部过路票
try
{
SqlDataReader sqlread = boperate.getread("SELECT sum(glp) as glp FROM tb_gpdd where '" + riqistart.Text.Trim() + "' <= ccrq and ccrq <= '" + riqiend.Text.Trim() + "' and cph='" + Convert.ToString(dgvAreaInfo.Rows[b].Cells[0].Value).Trim() + "' and jsfs = '内部用车' ");
if (sqlread.Read())
{
string zhi4 = sqlread["glp"].ToString();
this.dgvAreaInfo.Rows[b].Cells[8].Value = zhi4.ToString();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
}

//获取现金工票
try
{
SqlDataReader sqlread = boperate.getread("SELECT sum(gpjg) as xjgpjg FROM tb_gpdd where '" + riqistart.Text.Trim() + "' <= ccrq and ccrq <= '" + riqiend.Text.Trim() + "' and cph='" + Convert.ToString(dgvAreaInfo.Rows[b].Cells[0].Value).Trim() + "' and jsfs = '现金' ");
if (sqlread.Read())
{
string zhi5 = sqlread["xjgpjg"].ToString();
this.dgvAreaInfo.Rows[b].Cells[9].Value = zhi5.ToString();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
}

//获取现金客车补助
try
{
SqlDataReader sqlread = boperate.getread("SELECT sum(kcbz) as xjkcbz FROM tb_gpdd where '" + riqistart.Text.Trim() + "' <= ccrq and ccrq <= '" + riqiend.Text.Trim() + "' and cph='" + Convert.ToString(dgvAreaInfo.Rows[b].Cells[0].Value).Trim() + "' and jsfs = '现金' ");
if (sqlread.Read())
{
string zhi6 = sqlread["xjkcbz"].ToString();
this.dgvAreaInfo.Rows[b].Cells[10].Value = zhi6.ToString();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
}

//获取现金货车补助
try
{
SqlDataReader sqlread = boperate.getread("SELECT sum(buzhu) as xjbuzhu FROM tb_gpdd where '" + riqistart.Text.Trim() + "' <= ccrq and ccrq <= '" + riqiend.Text.Trim() + "' and cph='" + Convert.ToString(dgvAreaInfo.Rows[b].Cells[0].Value).Trim() + "' and jsfs = '现金' ");
if (sqlread.Read())
{
string zhi7 = sqlread["xjbuzhu"].ToString();
this.dgvAreaInfo.Rows[b].Cells[11].Value = zhi7.ToString();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
}

//获取现金过路票
try
{
SqlDataReader sqlread = boperate.getread("SELECT sum(glp) as xjglp FROM tb_gpdd where '" + riqistart.Text.Trim() + "' <= ccrq and ccrq <= '" + riqiend.Text.Trim() + "' and cph='" + Convert.ToString(dgvAreaInfo.Rows[b].Cells[0].Value).Trim() + "' and jsfs = '现金' ");
if (sqlread.Read())
{
string zhi8 = sqlread["xjglp"].ToString();
this.dgvAreaInfo.Rows[b].Cells[12].Value = zhi8.ToString();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
}
}
}


自定义DGV的列,将数据显示在不同列中,出现的错误提示。
...全文
120 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
criuslee 2014-12-15
  • 打赏
  • 举报
回复
引用 2 楼 sp1234 的回复:
你应该做的是让设计和实现 boperate.getread 方法的程序设计师,重新去设计它的程序接口。而你扔掉 boperate.getread 方法。
谢谢!我会研究下的!
  • 打赏
  • 举报
回复
你应该做的是让设计和实现 boperate.getread 方法的程序设计师,重新去设计它的程序接口。而你扔掉 boperate.getread 方法。
  • 打赏
  • 举报
回复
对于返回 DbDataReader 的 SqlHelper 方法,我们一直是反对的。因为使用者很容易就忘记(甚至根本不懂)需要及时通过它关闭所占用的数据库逻辑连接。而不及时释放逻辑连接,那么数据库连接池就会很快用尽。 所以好的 SqlHelper 返回的是查询对象集合,例如 List<T> 类型的,一旦你取出数据集合,那么数据库逻辑连接立刻就关闭了。及时关闭数据库连接,才能保证数据库连接池不会用尽。

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧