在系统的管理工具->数据源中新建一个sql server数据源:
Data Source=zloracle; UID=ZLIN;PWD=PASSWORD
lr脚本的代码:
char strconn[100]="DRIVER={Oracle in OraHome92};SERVER=208;Data Source=zloracle;UID=ZLIN;PWD=PASSWORD";
lr_load_dll("mfcdll.dll");
//加载DLL库
x=dbconnect(strconn);
mfcdll.dll(VC做的)中的代码:
int dbconnect(char strconn[])
{ // HRESULT
hResult;
int x=0;
//::AfxOleInit();
CoInitialize(NULL);
//
_bstr_t conn="DRIVER={Oracle in OraHome92};SERVER=208;Data Source=zloracle;UID=ZLIN;PWD=PASSWORD";
_bstr_t conn=(_bstr_t)strconn;//字符串转换成_bstr_类型
m_pConnection.CreateInstance("ADODB.Connection");
//
m_pConnection->Open(conn,"","",-1);
if
(SUCCEEDED(m_pConnection->Open(conn,"","",adModeUnknown)))
{
AfxMessageBox("已连接成功");
x=10;
}
else
AfxMessageBox("连接失败");
return x;
}