CoInitialize(NULL);
char *str;
str="(DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.11)(PORT = 1521)))(CONNECT_DATA =(SERVICE_NAME = ORCL)))";

_ConnectionPtr pConn(__uuidof(Connection));
_RecordsetPtr pRst(__uuidof(Recordset));
_CommandPtr pCmd(__uuidof(Command));

char *cs;


pConn->ConnectionString="Provider=OraOLEDB.Oracle.1;User ID=jichun;Password=jichun;Data Source=%s,str";
pConn->Open("","","",adConnectUnspecified);

pRst=pConn->Execute("select * from T_GPS",NULL,adCmdText);

while(!pRst->rsEOF)
{
cs=(_bstr_t)pRst->GetCollect("ID");
AfxMessageBox(cs);
pRst->MoveNext();
}

pRst->Close();
pConn->Close();
pRst.Release();
pConn.Release();
CoUninitialize();
---------------------------
0xe06d7363出错

解决方案 »

  1.   

    在执行pConn->Open("","","",adConnectUnspecified);时出错
      

  2.   

    pConn->ConnectionString="Provider=OraOLEDB.Oracle.1;User ID=jichun;Password=jichun;Data Source=%s,str";错了吧,目测CString strConnectionString;
    strConnectionString.Format("Provider=OraOLEDB.Oracle.1;User ID=jichun;Password=jichun;Data Source=%s",str);
    pConn->ConnectionString=(LPCTSTR)strConnectionString;
      

  3.   

    连接oracle的语句为:Provider=MSDAORA.1;Password=%s;User ID=%s;Data Source=%s;
    自己去补吧。
      

  4.   

    其中的Data Source是在远程oracle在本地配置好的服务名。