已有打开的与此命令相关联的DataReader,必须首先将它关闭
在程序的编写过程中,调用数据库的存储过程,根本就没有用到datareader,但是,程序老提示“打开的与此连接相关联的Datareader,必须首先将它关闭”,这是为什么呢?
如下面
DataTable dt = new DataTable();
SqlCommand comm = new SqlCommand("SelectUsersAll", conn.Conn);
comm.CommandType = CommandType.StoredProcedure;
SqlDataAdapter adapter = new SqlDataAdapter(comm);
adapter.Fill(dt);
if (conn.Conn.State == ConnectionState.Open)
conn.Conn.Close();
return dt;