C # Use System. Data. oracleclient to connect to the Oracle database. Previously running normally on WINXPProgramAfter porting to Windows 2008 x64, the database cannot be connected. The error message is as follows:
Badimagefomatexception is thrown when you try to load the Oracle client library. This problem occurs when the 32-bit Oracle client component is installed in 64-Bit mode.
The cause of the error is that the oracleinstantclient installed on the WINXP host is 32 bits, so the oracleclient used by the compiled program is also 32 bits, resulting in compatibility problems. Of course, if you reinstall the 64-bit Oracle client on the 64-bit operating system and re-compile the program, the problem can also be solved. Here we will introduce a simple method to transplant the program.
In fact, system. Data. oracleclient points to OCI. dll under the path environment variable. Therefore, we only need to allow the program to find the 64-bit OCI. dll. The method is as follows:
1. Download and unzip, such as c: \ instantclient-basic-win-x86-64-11.1.
2. Add the above path to the system environment variable path.
Then run the program. The program searches for OCI Based on the path. DLL, if you encounter a 32-bit OCI. the dll will automatically skip and find the 64-bit OCI. DLL to connect to the database.
For more information, see Jeffrey's blog.
Here we will update the patch connection:Http://www.oracle.com/technology/global/cn/software/tech/oci/instantclient/htdocs/winx64soft.html? _ Template =/ocom/print
Oracle client download link: http://www.oracle.com/technology/software/products/database/index.html
If not, please download oracle64-bit latest client: http://download.oracle.com/otn/nt/oracle10g/10204/10204_vista_w2k8_x64_production_client.zip
See this link for details: http://www.dbatoolz.com/t/installing-oracle-instantclient-basic-and-instantclient-sqlplus-on-win32.html