1.加入下列代码:
#include <icrsint.h>
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" \
no_namespace rename("EOF", "adoEOF")
编译时有警告产生,怎样排除这个警告?
d:\simulator\temp\msado15.tlh(405) : warning C4146: unary minus operator applied to unsigned type, result still unsigned
2.我不想通过链接ODBC链接数据库,而想直接链接数据库(像Delphi那样找到Localhost就行)。
#include <icrsint.h>
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" \
no_namespace rename("EOF", "adoEOF")
编译时有警告产生,怎样排除这个警告?
d:\simulator\temp\msado15.tlh(405) : warning C4146: unary minus operator applied to unsigned type, result still unsigned
2.我不想通过链接ODBC链接数据库,而想直接链接数据库(像Delphi那样找到Localhost就行)。
2,你在建立连接的时候,写连接串就可以了,看你连接串怎么写了
可以通过odbc也可以不通过odbc直接连接到数据库上
下面是我的程序,直接连到我的机器上的sql server 上
::CoInitialize(NULL);
m_pConnection.CreateInstance(_uuidof(Connection));
try
{
m_pConnection->Open("Provider=SQLOLEDB.1;Password=Yagopassword;Persist Security Info=True;User ID=sa;Initial Catalog=JapanBar;Data Source=(LOCAL)","","",0);
}
catch(_com_error& e)
{
AfxMessageBox(e.ErrorMessage());
GetDlgItem(IDC_RSTBTN)->EnableWindow(false);
}
no_namespace rename("EOF", "adoEOF")
加到stdafx.h中
你是谁?这里不欢迎Japan spooks.
no_namespace rename("EOF", "adoEOF")
加到stdafx.h中,注意要放在所有的include之后,我的程序就是这样添加的,没有出现编译警告。