很奇怪,我在我的工程里引入ado动态连接库
#import "c:\program files\common files\system\ado\msado15.dll"\
no_namespace\
rename("EOF","adoEOF")
可是出现下面的错误帮忙看一看是怎么回事?
warning C4185: ignoring unknown #import attribute 'no_namespacerename'
e:\zhangshuyan\xiangmugongcheng\chengxu11.23\debug\msado15.tlh(409) : warning C4146: unary minus operator applied to unsigned type, result still unsigned
e:\zhangshuyan\xiangmugongcheng\chengxu11.23\debug\msado15.tlh(1317) : error C2629: unexpected 'short ('
e:\zhangshuyan\xiangmugongcheng\chengxu11.23\debug\msado15.tlh(1317) : error C2238: unexpected token(s) preceding ';'
Error executing cl.exe.
#import "c:\program files\common files\system\ado\msado15.dll"\
no_namespace\
rename("EOF","adoEOF")
可是出现下面的错误帮忙看一看是怎么回事?
warning C4185: ignoring unknown #import attribute 'no_namespacerename'
e:\zhangshuyan\xiangmugongcheng\chengxu11.23\debug\msado15.tlh(409) : warning C4146: unary minus operator applied to unsigned type, result still unsigned
e:\zhangshuyan\xiangmugongcheng\chengxu11.23\debug\msado15.tlh(1317) : error C2629: unexpected 'short ('
e:\zhangshuyan\xiangmugongcheng\chengxu11.23\debug\msado15.tlh(1317) : error C2238: unexpected token(s) preceding ';'
Error executing cl.exe.
1.stdafx.h中加入
#import "C:\Program Files\Common Files\System\ado\msado15.dll" no_namespace rename("EOF","adoEOF")
2。app文件的InitInstance中加入
if(S_OK!=OleInitialize(NULL))
{
AfxMessageBox("初始化COM组件库错误");
}
下面就是数据库操作
_ConnectionPtr pConn;
_RecordsetPtr pRs;
CString strSQL;
pConn.CreateInstance(__uuidof(Connection));
pConn->CursorLocation=adUseClient;
strSQL="Provider=SQLOLEDB;Server=Gooyan;DataBase=SkillsBox;UID=sa;PWD=aaaaaaaa";
pConn->Open(_bstr_t(strSQL),"","",-1);pRs.CreateInstance(__uuidof(Recordset));
pRs->CursorLocation=adUseClient;
pRs->PutActiveConnection(pConn.GetInterfacePtr());pRs1.CreateInstance(__uuidof(Recordset));
pRs1->CursorLocation=adUseClient;
pRs1->PutActiveConnection(pConn.GetInterfacePtr());strSQL="select * from catalog order by cataid";
pRs->Open(_bstr_t(strSQL),vtMissing,adOpenDynamic,adLockBatchOptimistic,adCmdText);
可是运行时又说连接失败,确定数据库在目录下
可是我的access文件是在工程目录下啊
本人初学还请各位指教!
1.stdafx.h中加入
#import "C:\Program Files\Common Files\System\ado\msado15.dll" no_namespace rename("EOF","adoEOF")
2。app文件的InitInstance中加入
if(S_OK!=OleInitialize(NULL))
{
AfxMessageBox("初始化COM组件库错误");
}
下面就是数据库操作
_ConnectionPtr pConn;
_RecordsetPtr pRs;
CString strSQL;
pConn.CreateInstance(__uuidof(Connection));
pConn->CursorLocation=adUseClient;
strSQL="Provider=SQLOLEDB;Server=Gooyan;DataBase=SkillsBox;UID=sa;PWD=aaaaaaaa";
pConn->Open(_bstr_t(strSQL),"","",-1);pRs.CreateInstance(__uuidof(Recordset));
pRs->CursorLocation=adUseClient;
pRs->PutActiveConnection(pConn.GetInterfacePtr());pRs1.CreateInstance(__uuidof(Recordset));
pRs1->CursorLocation=adUseClient;
pRs1->PutActiveConnection(pConn.GetInterfacePtr());strSQL="select * from catalog order by cataid";
pRs->Open(_bstr_t(strSQL),vtMissing,adOpenDynamic,adLockBatchOptimistic,adCmdText);