SqlDataReader DataRead = frmMain.m_AccessDB.DownLoadFiles(RootInfo.iID, sYear.strName);
 while (DataRead.Read())
{
  .....
  if (backgroundWorker1.CancellationPending == true)
  {
   DataRead.Close()
   return false;
  }
}由于DataRead中数据量较大,我Close()的时候总是超时,(测试的时候,connection都是正常的)请问如何解决,谢谢。

解决方案 »

  1.   

    你确认指定到 DataRead.Close了吗
      

  2.   

     while (DataRead.Read())
    {
      .....
     }DataRead.Close()
    一般都是把close()放到循环外,不知是否与这有关。。
      

  3.   

    SqlDataReader的close超时时间是受你创建它使用的那个Command的CommandTimeout 属性支配的。
      

  4.   

    我不知道你的 DownLoadFiles 这是什么意思。不过关于存储量,以及性能,应该以实际使用为准。假设在生产服务器上跟你开发时不一样,那么可能你需要考虑是不是当初开发时的流程设计就有问题。
      

  5.   

    感谢楼上的兄弟,我再研究研究,我以为会有其他的什么办法来关闭SqlDataReader
      

  6.   

    if(dataread.Read())
    {
      ....
    }
    这样不一样吗?
      

  7.   

    请问d_hongran,using(){}有什么意义,学习一下。
      

  8.   


    楼上正解,应该给分!!//
            // 摘要:
            //     Gets or sets the wait time before terminating the attempt to execute a command
            //     and generating an error.
            //
            // 返回结果:
            //     The time in seconds to wait for the command to execute. The default is 30
            //     seconds.
            [ResDescription("DbCommand_CommandTimeout")]
            [ResCategory("DataCategory_Data")]
            public override int CommandTimeout { get; set; }
    默认是30秒 自己设一下吧