对一个有数万条记录的表进行 select * from table 后在文档图示中显示出来,程序执行数秒就没反应了,奇怪?难道 vc 这么差,打开个表都不行?

解决方案 »

  1.   

    我把显示部分去掉,只执行 select * from table 后
    m_pCommonRS->movefirst();
    while(!m_pCommonRS->IsEOF()){
    m_pCommonRS->MoveNext(); 
    }这样又正常。
    我的view 的基类是 CListView
      

  2.   

    样式是 report.BOOL CAbcdView::ShowInformation(CString strSQL)
    {
    CRect rect;
    CListCtrl& ctrlList = (CListCtrl&) GetListCtrl();
    ctrlList.GetWindowRect(rect); try{
    // get recordset field information
    BeginWaitCursor();
    if(m_pCommonRS->IsOpen()) m_pCommonRS->Close();
    m_pCommonRS->Open(CRecordset::snapshot, strSQL);
    if(!m_pCommonRS->IsEOF()){
    m_pCommonRS->MoveLast(); 
    m_pCommonRS->MoveFirst(); 
    }
    int nFieldCount = m_pCommonRS->GetODBCFieldCount();
    CODBCFieldInfo fieldinfo; 
    for(int n=0;n<nFieldCount;n++){
    m_pCommonRS->GetODBCFieldInfo(n, fieldinfo);
    int nWidth = ctrlList.GetStringWidth(fieldinfo.m_strName) + 50;
    ctrlList.InsertColumn(n, fieldinfo.m_strName, LVCFMT_LEFT, nWidth);
    }
    // get recordset data information
    CString strValue; 
    m_pCommonRS->MoveFirst(); 
    int nCount = 0; while(!m_pCommonRS->IsEOF()){
    ctrlList.InsertItem(nCount, strValue);
    for(int j=0;j<nFieldCount;j++){
    m_pCommonRS->GetFieldValue(j, strValue);
    ctrlList.SetItemText(nCount, j, strValue);
    }
    m_pCommonRS->MoveNext(); 
    nCount ++;
    }
    EndWaitCursor();
    } catch(CDBException *e){
    e->ReportError();
    EndWaitCursor();
    return FALSE;
    } return TRUE;
    }
      

  3.   

    这是ListView的问题,建议采用Virtual ListCtrl,网上有这方面的例子.
      

  4.   

    让listview实时更新试一下:m_pCommonRS->MoveNext(); ctrlList .Update(nCount );   //<---加入此句nCount ++;//太慢
      

  5.   

    计算滑块的位置,
    根据纪录个数按比例计算出RECORDSET的当前位置
    MOVE 到 该位置,添入数据
      

  6.   

    不要去分批显示了,听我的,用Virtual ListCtrl
    我现在开发的系统大部分都是用Virtual ListCtrl,以前也是你说的这种情况,也尝试过每次显示1000条,但效果不好
      

  7.   

    to ffit(ffit):
           if it is a free software
    send me a copy:[email protected] thanks
      

  8.   

    to 小楼:你的方法我试了,程序虽然没有出现“无响应”的状况,可是效果确实不好,等了很久才有显示。to ffit: Virtual ListCtrl 的资料哪里有?你能否提供一下地址?
      

  9.   

    http://www.vccode.com/vcfile/show.php?id=1287
      

  10.   

    应该是这个:
    http://codeguru.earthweb.com/listview/virtualListview.html
      

  11.   

    主要是慢在读去数据上,而不是显示纪录,建议使用forwardonly,并且在SERVER 端使用 RECORDSET,手工控制每次读出的纪录.
    TO FFIT:
    试过了,
    蛮不错,
    至少比直接用现成的好!
    谢谢
      

  12.   

    to fingerfox: 你能不能说得详细些?