xp系统vc60下写了一段代码,将一个excel文件的指定字段里的数据写入列表控件
问题很奇怪,这个while循环只执行了一次,当将文件中指定字段的第一个数据写入列表控件,随后进行第二次搜索时出现abnormal program termintion 错误
断点测试了一下,竟然是在 while(!m_pRecordset->adoEOF) 的时候停止并出错,为什么呢     int SelectSFCount = 1; while(!m_pRecordset->adoEOF)
{
for(int i=0; i<SelectSFCount; i++)
             { 
var = m_pRecordset->GetCollect((LPTSTR)(LPCTSTR)SelectCompareFieldName[i]);

if(var.vt != VT_NULL)
strName = (LPCSTR)_bstr_t(var);
if(i==0)Vm_listCtrl.InsertItem(0,strName);
else Vm_listCtrl.SetItemText(0,i,strName);
             }
             Vm_listCtrl.Update(0);     //刷新显示
            
m_pRecordset->MoveNext();  //执行完这句后,出现错误,难道不能移动指针了?
}感谢大家给予指导,我超级的困惑,谢了

解决方案 »

  1.   

         int SelectSFCount = 1; 
    m_pRecordset-> MoveFirst();  
    while(!m_pRecordset-> adoEOF) 

    for(int i=0; i <SelectSFCount; i++) 
                 {  
    var = m_pRecordset-> GetCollect((LPTSTR)(LPCTSTR)SelectCompareFieldName[i]); if(var.vt != VT_NULL) 
    strName = (LPCSTR)_bstr_t(var); 
    if(i==0)Vm_listCtrl.InsertItem(0,strName); 
    else Vm_listCtrl.SetItemText(0,i,strName); 
                 } 
                 Vm_listCtrl.Update(0);     //刷新显示 
                 
    m_pRecordset-> MoveNext();  //执行完这句后,出现错误,难道不能移动指针了? 
      

  2.   

    感谢大家的帮忙了,问题我找到了
    1、只填入一个数据是因为我限定了搜索字串:like '4%'
    2、出现abnormal program termintion 其实不是在这里,是这段代码的下一段路径指向出了问题仍然感谢大家的热心帮忙,zhoujianhei 给出的代码比较完整,谢谢
    结帖了