?? d144.bmp.txt
字號(hào):
m_Data.SetColumnWidth(2 ,55);
下面編輯函數(shù),實(shí)現(xiàn)對(duì)數(shù)據(jù)庫(kù)的操作。
1)顯示數(shù)據(jù)。在為記錄集創(chuàng)建對(duì)象實(shí)例后,添加成員函數(shù)ListData(),編輯該函數(shù),用
Recordset對(duì)象打開記錄集,并遍歷記錄集中的數(shù)據(jù),顯示在List控件中。在這之前需要定
義CRemoteDBApp對(duì)象的外部變量theApp。
144
extem CRemoteDBApp theApp;
void CRemoteDBDlg::ListData0
{
m_Data.DeleteAllltems();
|||||l||||l|……lll||||l|||||||川…ll|川…ll|||ll
//在ADO操作中建議語(yǔ)句中要常用try...catch()來(lái)捕獲錯(cuò)誤信息,
//因?yàn)樗袝r(shí)會(huì)經(jīng)常出現(xiàn)一些想不到的錯(cuò)誤
if (m_pRecordset->State)
m_pRecordset->Close();
try
{
m_pRecordset->Open( "SELECT+ FROM個(gè)人信息”, ,/查詢User表中所有字段
theApp.m_pConnection.GetlnterfacePtr(),,/獲取庫(kù)接庫(kù)的IDispatch指鐘
adOpenDynamic,
adLockOptimistic,
adCmdText);
)
catch(_com_error *e)
{
AfxMessageBox (e->ErrorMessage0);
)
|||川ⅢlI|||lⅢm…|l|川||ll|||||||l|||川…川|
CString strName,strSex,strAge;
if( !m_pRecordset->BOF)
m_pRecordset->MoveFirst0;
else
{
AfxMessageBox(”表內(nèi)數(shù)據(jù)為空”);
retum:
}
_vanant_t var;
inti= 0;
/////////iE~~
try
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -