问个循环填充的问题
try
{
GridView4.Visible = true;
string sql = "select username from surveylog where SurveyStatus='有效'";
con = new SqlConnection(str);
con.Open();
com = new SqlCommand(sql, con);
read = com.ExecuteReader();
while (read.Read())
{
string name = read["username"].ToString();
read.Close();
string sql1 = "select Email,AlternateEmail from member where username='" + name + "'";
SqlDataAdapter ada = new SqlDataAdapter(sql1, con);
//read.Close();
DataSet ds = new DataSet();
ada.Fill(ds);
GridView4.DataSource = ds;
GridView4.DataBind();
}
con.Close();
}
catch(Exception ex)
{
ex.ToString();
}
阅读器关闭时 Read 的尝试无效。请问这个要怎么解决啊?谢谢