-1

I lost half day trying to connect my old VB6 app (VB6 is 32 bit only, so supports only 32 bit ODBC drivers) to an Oracle database through ODBC. It is a different question if you have the app in VB.NET, you have more choices, as the response from @Wernfried indicates.

The problem was that the Windows 64 bit server has an Oracle 11g 64 bit install in production, so only ODBC 64 bit was available. I didn't want to cause problems on that installation so my idea was to add only the essential to allow ODBC 32 bit Oracle driver to be available in the system.

I want to share my solution that maybe can help others in the future (or myself).

Eagle
  • 978
  • 1
  • 14
  • 27
  • See https://stackoverflow.com/questions/24104210/badimageformatexception-this-will-occur-when-running-in-64-bit-mode-with-the-32#24120100 – Wernfried Domscheit Sep 08 '21 at 11:04
  • There are also other drivers available in 32-bit - not only ODBC, see http://stackoverflow.com/questions/34803106/how-to-connect-to-oracle-11-database-from-net/34805999#34805999 – Wernfried Domscheit Sep 08 '21 at 11:06

1 Answers1

0

NOTE: this solution is just for an specific case, the case when you need only ODBC 32-bit working on the 64-bit system. Other apps that rely on 32-bit DLLs may not work because will not find it.

The idea is to add instaclient 32 bit to the server manually, so nothing will interfere in the main system. We will need basic instaclient + ODBC instaclient

Follow these steps:

  • Download from https://www.oracle.com/database/technologies/instant-client/downloads.html the 32-bit instaclient and the 32-bit ODBC (instantclient-basic-win32-11.1.0.7.0.zip and instantclient-odbc-win32-11.1.0.7.0.zip)
  • It is installed simply by unzipping in a folder, for example, C:\instaclient_11_2
  • The instaclient ODBC must be also unzipped in that folder and then, you need to execute odbc_install.exe. After it, you have Oracle ODBC 32 bit available in the system.
  • Instructions says to Add the folder C:\instaclient_11_2 to the system PATH, but it is not necessary just for ODBC to work. In fact, in order to leave system as untouched as possible, don't do it.
  • Add, so that the Oracle ODBC 32 bit driver recognizes your tnsnames.ora file, the environment variable TNS_ADMIN with the value C:\instaclient_11_2 and copy in that folder the original tnsnames.ora from your Oracle home network\admin folder.

At this point, you have the 32 bit ODBC driver available and with Oracle tnsnames.ora configured.

  • Go to the C:\Windows\SysWOW64 folder and run odbcad32.exe there to create Oracle's native 32-bit ODBC driver for your app and test the connection. That's all.

NOTE: if when creating the ODBC driver at this step, appears this error: "The Setup routines for the Oracle in instantclient_11_2 ODBC driver could not be loaded due to system error code 14001: The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log or use the command-line sxstrace.exe tool for more detail. (.. \ SQORAS32.DLL)."

Then the VC++ 2005 redistributable is missing. Go to https://www.microsoft.com/en-US/download/details.aspx?id=14431, download the 32-bit version and install. Then it should work.

No system restarts are needed, no current Oracle install is affected. All should work as fine as before but with Oracle ODBC 32 bit available and working.

Eagle
  • 978
  • 1
  • 14
  • 27
  • Will not work. The folders are evaluated in the order as they appear in the `PATH` environment variable. If you put `C:\instaclient_11_2` to the end, then the application will access the 64-bit version (and fail). If you put `C:\instaclient_11_2` at the beginning the other 64-bit applications will stop working. See proper instruction in my comment above. – Wernfried Domscheit Sep 08 '21 at 11:04
  • Will not work... but it is currently working. Maybe ODBC will not need the 32 bit DLLs (although instructions say it) but the real fact is that the system is working properly, and I have the ODBC 32 bit driver working too. By the way, the order in PATH was 64-bit version, then 32-bit – Eagle Sep 08 '21 at 16:04
  • 1
    I doubt that a 64-bit and a 32-bit application will work at the same time at this machine. Maybe ODBC is an exception, because the driver DLL location is specified in the registry rather than rely on `PATH` - you may test with [Oracle Connection Tester](https://github.com/Wernfried/connection-tester) – Wernfried Domscheit Sep 08 '21 at 19:34
  • Please try upgrading to a more recent version of the Oracle Client ! – Christopher Jones Sep 08 '21 at 23:32
  • What you say, @WernfriedDomscheit, makes all the logic. Other apps that rely on 32-bit DLLs probably won't work. But my specific need was for only ODBC 32-bit to work and this method, without further complications, is working. So, I think it may be a valid solution and this is because I wrote this guide (different from others more complicated that I found here). – Eagle Sep 09 '21 at 06:45
  • Ok, more info @WernfriedDomscheit: I removed the PATH and still working so... ODBC is not using the path `C:\instantclient_11_2` as you suspected. Will edit my post now to reflect it. – Eagle Sep 09 '21 at 07:05
  • In deed, I also tested it. ODBC is working. However, when your application uses the OleDB provider (no matter if the provider from Microsoft or from Oracle) then it fails. OPD.NET providers which are not registered in GAC would also fail. – Wernfried Domscheit Sep 09 '21 at 07:39