标题:执行后提示:阅读器关闭时 Read 的尝试无效。
只看楼主
jinjinanni
Rank: 1
等 级:新手上路
帖 子:27
专家分:0
注 册:2007-6-19
结帖率:25%
 问题点数:0 回复次数:0 
执行后提示:阅读器关闭时 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 的尝试无效。
是在哪里错了..
搜索更多相关主题的帖子: Read 尝试 阅读 提示 
2008-10-29 10:39



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-241246-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.023139 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved