odbc数据库连接问题
CDatabase db;
CString szSQL;
CString szName,szBook,szAuthor;
int iRec=0;
int nCount=0;
try
{
db.Open(NULL,false,false,"ODBC;DSN=book;UID=;PWD=;");
CRecordset rt(&db);
szSQL="SELECT * FROM book";
rt.Open(CRecordset::forwardOnly,szSQL);
m_ListCtrl.DeleteAllItems();
while(!rt.IsEOF())
{
rt.GetFieldValue("书名",szName);
rt.GetFieldValue("书号",szBook);
rt.GetFieldValue("作者",szAuthor);
m_ListCtrl.InsertItem(nCount,szName);
m_ListCtrl.SetItemText(nCount,1,szBook);
m_ListCtrl.SetItemText(nCount,2,szAuthor);
nCount++;
rt.MoveNext();
}
rt.Close();
}
catch(CDBException* e)
{
AfxMessageBox("Database error:"+e->m_strError);
}
列表框没反应····
是什么问题
请高手指点下