void CLocation::OnDuanming() 
{
// TODO: Add your control notification handler code here
   BOOL hasRec = FALSE;
int exe = 0;
m_listctrl1.DeleteAllItems();
CString TempSql;
int i = -1;
  CString  sql;
  sql="SELECT* FROM duanming";
    exe=pApp->m_database.ExecuteSQL(sql,pApp->m_crecordset);

while(pApp->m_crecordset->EndOfFile)
 {
        LV_ITEM lvitem;
lvitem.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_STATE;
lvitem.state = 0;      
lvitem.stateMask = 0; 
char temp[50];

lvitem.iItem = ++i;
lvitem.iSubItem = 0;
lvitem.pszText =itoa(i, temp, 10); 
m_listctrl1.InsertItem(&lvitem);
            TempSql=(char*)(_bstr_t)pApp->m_crecordset->GetCollect("段名");
m_listctrl1.SetItemText(i, 1, (LPCTSTR)TempSql);
            TempSql=(char*)(_bstr_t)pApp->m_crecordset->GetCollect("index");
m_listctrl1.SetItemText(i, 2, (LPCTSTR)TempSql);
pApp->m_crecordset->MoveNext();
 }

}
 请问 一下这个有什么代码的问题么。执行没问题。但数据库中的数据不显示。

解决方案 »

  1.   

    你调试一下,程序进入到了while(pApp->m_crecordset->EndOfFile) 代码内部运行了吗??
      

  2.   

    出现了 Loaded'C:\WINDOWS\system32\ole32.dll,no matching symbolic information found 
     是什么原因呢,用ADO来编程,我里面用得函数对么?
      

  3.   

    你代码中用的ADO像是被封装过的..所以看不出有什么问题...
    用如下代码把你的代码包起来
    try 

        //你的代码 

    catch(_com_error &e) 

        AfxMessageBox(e.Description()); 

    看看能否捕获异常??
      

  4.   

    不知你加了下面的初始化没??#import "c:\program files\common files\system\ado\msado15.dll" no_namespace rename("EOF","adoEOF")//另外还要在初始时加入下面的代码
    AfxOleInit(); //初始化COM库