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();
}
}
请问 一下这个有什么代码的问题么。执行没问题。但数据库中的数据不显示。
{
// 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();
}
}
请问 一下这个有什么代码的问题么。执行没问题。但数据库中的数据不显示。
是什么原因呢,用ADO来编程,我里面用得函数对么?
用如下代码把你的代码包起来
try
{
//你的代码
}
catch(_com_error &e)
{
AfxMessageBox(e.Description());
}
看看能否捕获异常??
AfxOleInit(); //初始化COM库