在RptPick.DataBind();
之后就可DR.CLOSE了
只有在RptPick.DataBind()绑定完成之后才能关闭DATAREADER

解决方案 »

  1.   

    a DataReader binds intimately with the connection object, you have to close the DataReader or Connection object after you are done with them. If you want to pass something around, you'd better use DataSet, since it is disconnected with the Connection objector try something liketry
    {
    //得到datareader
    ConnectDB();
    OleDbCommand cmd=new OleDbCommand(StrSql,Conn);
    Dr=cmd.ExecuteReader(CommandBehavior.CloseConnection);
    }
    catch(OleDbException eErr)
    {
    SqlErrorHandler(eErr);
    }
    finally
    {
    //Conn.Close();
    }
    //....
    DrNewMessage=Db.GetDr(StrSelect);
    RptPick.DataSource=DrNewMessage;
    RptPick.DataBind();
    DrNewMessage.Close();
      

  2.   

    这时DrNewMessage.Close();是不是可以把组件中的Conn关闭?可以肯定的是:DrNewMessage.Close();一定是放在外面?
      

  3.   

    Dr=cmd.ExecuteReader(CommandBehavior.CloseConnection);CommandBehavior.CloseConnection:
    When the command is executed, the associated Connection object is closed when the associated DataReader object is closed.
      

  4.   

    阅读器DataAdapter在连接关闭的情况下,是无法进行read(),fieldCount()...操作的.思归说得对,为了使用DataAdapter,只有保持Connection保持打开.  Conn.Close()不要放在你的GetDr()方法中.而是在调用后才关闭