Use of ODBC connection in win2003 64 bit system

  • 2020-06-07 05:48:03
  • OfStack

The environment

If the windows system is deployed, the 64-bit win2003 will be adopted. However, most of the programs we wrote were compiled in the 32-bit cpu architecture under x86, so it was really troublesome to migrate to a 64-bit machine. It required not only the application to be compiled in 64-bit mode, but also the database to be compiled in 64-bit, iis64-bit, framework64-bit. Fortunately, the corresponding vendors provided these supporting components. I don't know if anyone has encountered such a problem like me. There is a need to add an Access database import function in the application, which requires connecting to the mdb driver of ODBC. However, Microsoft OLE DB Provider for Jet does not support 64-bit system.

Analysis of the

The structure of 64-bit system is analyzed.

c disk has two program installation directories: Program Files and Program Files (x86);
There are two directories under the windows folder: System32 and SysWOW64;
There are no other drivers in odbcad32.ES39en in System32 (this is also the program started directly by ODBC in the control panel), but in SysWOW64 odbcad32.ES43en there are all drivers like mdb, which indicates that THE ODBC driver exists in the operating system, and the corresponding driver cannot be found due to the different odbc program called due to the running mode. With this in mind, you can find a solution: switch the 64-bit run mode to 32-bit.

Solving steps

Switch the IIS run mode to 32 bits

Start → Run →cmd, run the script:


cscript %SYSTEMDRIVE%\inetpub\adminscripts\adsutil.vbs SET W3SVC/AppPools/Enable32bitAppOnWin64 1

You can switch IIS from 64-bit to 32-bit mode. To restore to a 64 - bit mode, run the script: SYSTEMDRIVE cscript % % \ inetpub \ adminscripts \ adsutil vbs SET W3SVC AppPools/Enable32bitAppOnWin64 0. If the script complains, switch the path to C:\Inetpub\AdminScripts because the adsutil.vbs file is in that path.

Asp. net runs in 32-bit mode

Re-register ES84en.ES85en, start → run →cmd

Run script: %SYSTEMROOT%\Microsoft.NET\Framework\v2.0.40607\aspnet_regiis.exe -i .

To register 64-bit, the script is: %SYSTEMROOT%\Microsoft.NET\Framework64\v2.0.40607\aspnet_regiis.exe -i .

Restart the machine and IIS is ready to run the 32-bit program and the connection to ODBC is in effect.

Oracle64-bit toggle to 32-bit

If the system was previously running in 64-bit mode using 64-bit oracle, the program's database connection will fail after changing to 32-bit mode, and the program will report: "If you are running in 64-bit mode with 32-bit Oracle client components installed..." This is a mistake. The natural answer is to install another 32-bit oracle client. The easiest way is to download the ORALCE toolkit Instant Client Package. Unzip it to any folder, such as D:\oracle\instantclient_11_2.

Set the corresponding environment variables: right click On My computer, Properties, Advanced, Environment variables, system environment variables:
1, new NLS_lANG=SIMPLIFIED CHINESE_CHINA.ZHS16GBK (note the space in the middle, if this is not set, toad query Chinese will be confused)
2. Create or modify TNS_ADMIN=D:\oracle\instantclient_11_2
3. Modify Path, add D:\oracle\instantclient_11_2, and delete the path of the original 64-bit oracle

The first of these is important to resolve the error running times: ES137en-12705: cannot data files or environment specified.

Create a new text file and change the suffix reg to read as follows:


Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\KEY_OraClient10g_home1] 
 " NLS_LANG " = " SIMPLIFIED CHINESE_CHINA.ZHS16GBK "  
 " ORACLE_BUNDLE_NAME " = " Standard "  
 " ORACLE_GROUP_NAME " = " Oracle  �  OraClient10g_home1 "  
 " ORACLE_HOME " = " D:\oracle\instantclient_11_2 "  
 " ORACLE_HOME_KEY " = " SOFTWARE\\ORACLE\\KEY_OraClient10g_home1 "  
 " ORACLE_HOME_NAME " = " OraClient10g_home1 " 

Double-click to import the registry.

Copy the tns file for 64-bit oracle to D:\oracle\instantclient_11_2, or run it: ORA-12154: TNS: not the identifier specified.

After the above modification, restart the computer, run the website program, found that 1 all as expected 1 kind of work!

Good luck to you all!


Related articles: