执行后提示:阅读器关闭时 Read 的尝试无效。
SqlConnection conn = Class1.CreateSql();conn.Open();
string sql = "select VoteID,VoteTitle,VoteSum from VoteMaster";
SqlCommand cmd = new SqlCommand(sql, conn);
SqlDataReader sdr = cmd.ExecuteReader();
while (sdr.Read())
{
Response.Write(sdr.GetString(1) + "—" + sdr.GetInt32(2) + "<br>");
if (!sdr.IsClosed)
{
sdr.Dispose();
}
string sql1 = "select MasterID,MasterItem ,Num from Master";
SqlCommand cmd1 = new SqlCommand(sql1, conn);
SqlDataReader sdr1 = cmd1.ExecuteReader();
while (sdr1.Read())
{
Response.Write(sdr1.GetString(1) + "—" + sdr1.GetInt32(2) + "<br>");
}
}
conn.Close();
执行后提示:阅读器关闭时 Read 的尝试无效。
是在哪里错了..