这是什么错啊
我的代码是这样的
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
ImageButton imgbutton = e.Row.FindControl("ImageButton1") as ImageButton;
if (imgbutton != null)
{
imgbutton.ImageUrl = "~/image/wr.gif";
if (imgbutton.ImageUrl == "~/image/wr.gif")
{
string mystr = "Data Source=zdxs;Initial Catalog=htoa;User ID=sa;Password=0";
SqlConnection myconn = new SqlConnection(mystr);
string sql = "select * from task_view";
myconn.Open();
SqlDataAdapter da = new SqlDataAdapter(sql, myconn);
DataSet ds = new DataSet();
da.Fill(ds);
GridView1.DataSource = ds.Tables[0];
GridView1.DataBind();
myconn.Close();
}
}
}
+1楼主以后在使用DataReader的时候,千万要注意记得及时关闭,不然就会出现你现在这样的错误
DataSet ds = new DataSet();
da.Fill(ds);这种方式不需要打开和关闭连接(断开式的)
myConnection.ConnectionString = "...Connect Timeout=30 ";