Reputation: 797
SOLVED: My VC++ application was in 32 bit and my Oracle DB was in 64 bit. I initially though that the client would work with both versions of Oracle, however, it doesn't. I thus solved the problem by reinstalling Oracle 11g2 32bit.
I'm trying to connect to a test Oracle 11g2 database via Visual Studio 2008 in C++. My database instance name is ORCL.TEST.DB, and the for testing purposes, I try to connect with user:SYSTEM and password:admin. I'm also using the Oracle OLE DB connector.
As you can see, I'm not trying anything fancy, I'm merely trying to successfully connect.
CDataSource ds;
CSession session;
int _tmain(int argc, _TCHAR* argv[])
{
try{
// fire up COM
HRESULT hr = CoInitialize(0);
if(FAILED(hr))
{
cout << "Can't start COM!? " << endl;
return -1;
}
/// connect to the database
//hr = ds.Open(L"OraOLEDB.Oracle", _T("ORCL"), _T("SYSTEM"), _T("admin"));
hr = ds.OpenFromInitializationString(L"Provider=OraOLEDB.Oracle;Data Source=ORCL.TEST.DB;User Id=SYSTEM;Password=admin");
if(FAILED(hr))
{
////////////////THIS IS WHERE IT ENDS UP
cout << "Can't open db" << endl << hr << endl;
return -1;
}
}
catch(...){
cout << "Unknown failure" << endl;
return -1;
}
return 0;
}
The error code hr contains is 80004005, which is E_FAIL (unspecified failure).
At first I thought it was a 32 vs 64 issue (64bit OS and 64bit Oracle, but 32bit C++ compiler in Visual Studio 2008). So I installed Oracle's Instant Client 32bit but it did not solve my problem.
Any ideas?
Upvotes: 0
Views: 3332
Reputation: 18843
The Microsoft ODBC driver for Oracle is very old and not supported.The support for Oracle database and drivers is at Oracles Web Site. I suggest you visit Oracle Site Oracle Network and register for an Account which is no cost.Then after you have joined the Oracle Network check the download sectio for Visual Studio Tools for Oracle and look for the ODAC112021xcopy.zip package for X64 or X86 which contains the updated runtime drivers for Windows.
After you have downloaded the runtime drivers read the guides at oracle for install.The new driver for Oracle will appear in the ODBC manager you then can update "your connection string" to use the new driver.If you can not connnect to the Oracle database the problem typically are the tns.listener connection settings. Typical settings use XE.NAME for the server instance. You will need to open the firewall for port 1521 to allow connections. If you look at the ora error which is oraXXXX message and search (Goolge or Bing) there are place on the Web that show how to change the tns listener for the Oracle Database engine. If you have problems with the connection string you can (Google or Bing) Connection Strings. If you have IIS Server errors then read the IIS Net library guides for Enabling and Turning on "Failed Request Tracing"
Upvotes: 1