|
? |
使用ADO前必须在工程的stdafx.h文件最后用直接引入符号#import引入ADO库文件,以使编译器能正确编译。代码如下:
#import "C:\Program Files\common files\system\ado\msado15.dll" no_namespace rename("EOF","adoEOF")
|
BOOL CAdoDlg::OnInitDialog()
{
CDialog::OnInitDialog();
m_list.InsertColumn(0,"spbh",LVCFMT_LEFT,50,-1);
m_list.InsertColumn(1,"spmch",LVCFMT_LEFT,50,-1);
m_list.InsertColumn(2,"spid",LVCFMT_LEFT,50,-1);
m_list.InsertColumn(3,"jlgg",LVCFMT_LEFT,50,-1);
m_list.InsertColumn(4,"shpchd",LVCFMT_LEFT,50,-1);
m_list.InsertColumn(5,"shengccj",LVCFMT_LEFT,50,-1);
m_list.InsertColumn(6,"dw",LVCFMT_LEFT,50,-1);
m_list.InsertColumn(7,"shpgg",LVCFMT_LEFT,50,-1);
m_list.InsertColumn(8,"denglrq",LVCFMT_LEFT,50,-1);
m_list.InsertColumn(9,"beactive",LVCFMT_LEFT,50,-1);
m_list.InsertColumn(10,"tongym",LVCFMT_LEFT,50,-1);
::CoInitialize(NULL);
//ADO 对象的实例化必须在COM环境初始化之后
m_pConn.CreateInstance(_uuidof(Connection));
m_pRs.CreateInstance(_uuidof(Recordset)); //
m_pConn->Open("DSN=ccerp_jt","x","x",adConnectUnspecified); //open database connection dsn,username,password,openmode :adConnectUnspcified,adAsynConnect(异步)
return TRUE;
}