public partial class info_xd : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
ysconn con1 = new ysconn();
con1.sqlString = "select * from ys_info where info_id='" + Request.QueryString["info_id"] + "'";
SqlDataReader rs = con1.recordset();
int m, j;
string A;
string[] tmpA = new string[1];
if (rs.HasRows)
{
rs.Read();
info_id.Text = rs["info_id"].ToString();
project_id.Text = rs["project_id"].ToString();
jbsj.Text = rs["p_jbsj"].ToString();
jbdz.Text = rs["p_gcdz"].ToString(); }
rs.Close();
con1.Close();
con1.sqlString = "select x_yslx from ys_xq where info_id='" + Request.QueryString["info_id"] + "' group by x_yslx";
rs = con1.recordset();
while (rs.Read())
{
for (m = 0; m < this.yslx.Items.Count; m++)
{
if (rs[0].ToString() == this.yslx.Items[m].Value)
{
this.yslx.Items[m].Selected = true;
this.yslx.Items[m].Enabled = false;
}
} }
con1.Close();
con1.CloseConn();
}
protected void Button1_Click(object sender, EventArgs e)
{ int m;
for (m = 0; m < this.yslx.Items.Count; m++)
{
if (this.yslx.Items[m].Selected == true)
{
ysconn con2 = new ysconn();
con2.sqlString = "select x_yslx from ys_xq where info_id='" + Request.QueryString["info_id"] + "' group by x_yslx";
SqlDataReader rs = con2.recordset();
rs = con2.recordset();
while (rs.Read())
{
Response.Write("test"); }
}
}
}
}执行Button1_Click始终显示
异常详细信息: System.InvalidOperationException: 连接未关闭。连接的当前状态为已打开。源错误:
行 52: SqlCommand mycom = new SqlCommand(_sqlString, mycon);
行 53:
行 54: mycon.Open();
行 55: SqlDataReader reader = mycom.ExecuteReader();
行 56: return reader;
源文件: e:\test\webfolder\App_Code\ysconn.cs 行: 54
{
protected void Page_Load(object sender, EventArgs e)
{
ysconn con1 = new ysconn();
con1.sqlString = "select * from ys_info where info_id='" + Request.QueryString["info_id"] + "'";
SqlDataReader rs = con1.recordset();
int m, j;
string A;
string[] tmpA = new string[1];
if (rs.HasRows)
{
rs.Read();
info_id.Text = rs["info_id"].ToString();
project_id.Text = rs["project_id"].ToString();
jbsj.Text = rs["p_jbsj"].ToString();
jbdz.Text = rs["p_gcdz"].ToString(); }
rs.Close();
con1.Close();
con1.sqlString = "select x_yslx from ys_xq where info_id='" + Request.QueryString["info_id"] + "' group by x_yslx";
rs = con1.recordset();
while (rs.Read())
{
for (m = 0; m < this.yslx.Items.Count; m++)
{
if (rs[0].ToString() == this.yslx.Items[m].Value)
{
this.yslx.Items[m].Selected = true;
this.yslx.Items[m].Enabled = false;
}
} }
con1.Close();
con1.CloseConn();
}
protected void Button1_Click(object sender, EventArgs e)
{ int m;
for (m = 0; m < this.yslx.Items.Count; m++)
{
if (this.yslx.Items[m].Selected == true)
{
ysconn con2 = new ysconn();
con2.sqlString = "select x_yslx from ys_xq where info_id='" + Request.QueryString["info_id"] + "' group by x_yslx";
SqlDataReader rs = con2.recordset();
rs = con2.recordset();
while (rs.Read())
{
Response.Write("test"); }
}
}
}
}执行Button1_Click始终显示
异常详细信息: System.InvalidOperationException: 连接未关闭。连接的当前状态为已打开。源错误:
行 52: SqlCommand mycom = new SqlCommand(_sqlString, mycon);
行 53:
行 54: mycon.Open();
行 55: SqlDataReader reader = mycom.ExecuteReader();
行 56: return reader;
源文件: e:\test\webfolder\App_Code\ysconn.cs 行: 54
con1.Close();
con1.CloseConn();