我用vc打开一个有几万条纪录的表并显示出来,程序运行数秒后就无反映了 对一个有数万条记录的表进行 select * from table 后在文档图示中显示出来,程序执行数秒就没反应了,奇怪?难道 vc 这么差,打开个表都不行? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我把显示部分去掉,只执行 select * from table 后m_pCommonRS->movefirst();while(!m_pCommonRS->IsEOF()){ m_pCommonRS->MoveNext(); }这样又正常。我的view 的基类是 CListView 样式是 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;} 这是ListView的问题,建议采用Virtual ListCtrl,网上有这方面的例子. 让listview实时更新试一下:m_pCommonRS->MoveNext(); ctrlList .Update(nCount ); //<---加入此句nCount ++;//太慢 计算滑块的位置,根据纪录个数按比例计算出RECORDSET的当前位置MOVE 到 该位置,添入数据 不要去分批显示了,听我的,用Virtual ListCtrl我现在开发的系统大部分都是用Virtual ListCtrl,以前也是你说的这种情况,也尝试过每次显示1000条,但效果不好 to ffit(ffit): if it is a free softwaresend me a copy:[email protected] thanks to 小楼:你的方法我试了,程序虽然没有出现“无响应”的状况,可是效果确实不好,等了很久才有显示。to ffit: Virtual ListCtrl 的资料哪里有?你能否提供一下地址? http://www.vccode.com/vcfile/show.php?id=1287 应该是这个:http://codeguru.earthweb.com/listview/virtualListview.html 主要是慢在读去数据上,而不是显示纪录,建议使用forwardonly,并且在SERVER 端使用 RECORDSET,手工控制每次读出的纪录.TO FFIT:试过了,蛮不错,至少比直接用现成的好!谢谢 to fingerfox: 你能不能说得详细些? 自己写的软键盘程序,希望大家关注,小撒分数 CFrameWnd 框架调整 单文档程序,按下键盘的Num Lock键,程序右下角的状态栏里会出现“数字"字符,怎么去掉? CListCtrl中如何改变行高 那里有NI-DAQ数据采集的编程资料啊 请问 VC中 可以不让自己定义的类显示在 类视图 上吗? 为什么程序无法运行? Com+组件访问的问题 高手,请问这个字符表怎么存储?是编译原理中的。 请教win98下断开nt,2000主机网络连接的方法,msdn里面说的不清楚。。 求助!!!如何改变某个控件的颜色 问?
m_pCommonRS->movefirst();
while(!m_pCommonRS->IsEOF()){
m_pCommonRS->MoveNext();
}这样又正常。
我的view 的基类是 CListView
{
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;
}
根据纪录个数按比例计算出RECORDSET的当前位置
MOVE 到 该位置,添入数据
我现在开发的系统大部分都是用Virtual ListCtrl,以前也是你说的这种情况,也尝试过每次显示1000条,但效果不好
if it is a free software
send me a copy:[email protected] thanks
http://codeguru.earthweb.com/listview/virtualListview.html
TO FFIT:
试过了,
蛮不错,
至少比直接用现成的好!
谢谢