#pragma warning (disable: 4146)
#import "c:\program files\common files\system\ado\msado15.dll" no_namespace rename ("eof", "adoeof")
// todo: add extra initialization here
m_listlinkinfo.setextendedstyle(lvs_ex_gridlines|lvs_ex_fullrowselect);
int i=0;
m_listlinkinfo.insertcolumn(i++, "姓名", lvcfmt_left, 90);
m_listlinkinfo.insertcolumn(i++, "**", lvcfmt_left, 90);
m_listlinkinfo.insertcolumn(i++, "郵件", lvcfmt_left, 100);
m_listlinkinfo.insertcolumn(i++, "位址", lvcfmt_left, 120);
m_listlinkinfo.insertcolumn(i++, "郵編", lvcfmt_left, 90);
m_listlinkinfo.insertcolumn(i++, "id", lvcfmt_left, 0);
m_cmbcondition.setcursel(0);
// 初始化com
afxoleinit();
showitem("select * from linkinfo");
return true; // return true unless you set the focus to a control
}void cmyadodlg::showitem(cstring strsql)
catch(_com_error e)
_recordsetptr m_precordset;//建立記錄集物件指標
m_precordset.createinstance(__uuidof(recordset));//建立記錄集物件例項
trycatch(_com_error *e)
_variant_t var;
int i=0, j=0;
cstring strtmp;
while(!m_precordset->adoeof)
m_precordset->close();
m_precordset.release();
m_precordset = null;
if(m_pconnection->state)
m_pconnection->close(); //關閉與資料庫的連線
m_pconnection= null;
updatedata(false);
}
ado讀取資料庫
當我們在使用ado運算元據庫的時候經常會碰到一些問題!例如資料庫為空我們就應該對是否為空做出判斷!variant t var var bstr t m precordset getcollect z controllersn if var.vt vt null else m list.setitem...
ADO 訪問資料庫
using system using system.collections.generic using system.componentmodel using system.data using system.drawing using system.text using system.window...
ADO資料庫示例
stdafx.h import c program files common files system ado msado15.dll no namespace rename eof nul adodlg.cpp coinitialize null connectionptr spconn uuid...