I. Summary
In C # development process, often need to operate the Oracle database, and actually in the deployment of the program, often according to the system environment (32, 64bit), do not install the Oracle client and so on, and odp.net there is no perfect compatible class library, the application can be called, So the deployment always encountered a variety of problems, very headache, here, I have to work on the problems encountered in the summary.
Two. Outline of this article
Connection mode
32-bit system
64-bit system
Free to install Oracle client
Summary
Three. Main content
Connection mode
C # Connect Oracle in a way that I usually connect via odp.net
<configuration> <connectionStrings> <add name="oracledb" connectionstring="Data source= (description= (address= (protocol=tcp) (host= database IP address) (port=1521)) ( Connect_data= (service_name= instance name)); User id= account; password= password; Min Pool size=10; Connection lifetime=120; Connection timeout=60;incr Pool size=5; DECR Pool size=2" providername="Oracle.DataAccess.Client"/> </connectionStrings></configuration>
32-bit system
1. Install the Oracle client: Odtwithodac1120320_32bit
2. Direct call can, nothing to say, if you want to install the client, the following will be said
64-bit environment
- Extract the Odac121012xcopy_x64.zip to a directory on the disk, such as "D:\ODAC121012Xcopy_x64.zip", then enter the directory at the command line and enter the following command: "Install.bat all \ c \ Odp.net myhome (Install all components) ".
- After running the above command, all the files will be automatically copied to the C:\odp.net directory, then, at the command line into the C:\odp.net directory, run the command: "Configure.bat all MyHome (Configure all component) ”。 The above command will automatically want the GAC to register odp.net related DLLs, while adding references in vs2010 to see the version of Oracle.DataAccess.dll.
- Finally, we need to add the system environment variable path, c:\odp.net;c:\odp.net\bin;
The configuration file is added
<runtime> <assemblybinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyidentity name="oracle.dataaccess"publickeytoken="89b483f429c47342"Culture="Neutral"/> <bindingredirect oldversion="0.0.0.0-4.121.1.0"newversion="4.121.1.0"/> </dependentAssembly> </assemblyBinding> </runtime>
To install the Oracle client:
Extract the class library files from the 5 Oracle clients and place them in the root of the program, respectively Oci.dll, Oracle.DataAccess.dll, Orannzsbb11.dll, Oraociei11.dll, OraOps11w.dll
<system.data> <DbProviderFactories> <add name="Oracle data Provider for. NET " invariant="Oracle.DataAccess.Client" description="Oracle Data Provider for. NET" type="Oracle.DataAccess.Client.OracleClientFactory, Oracle.dataaccess, version=4.112.2.0, culture=neutral, publickeytoken=89b483f429c47342"/> </DbProviderFactories> </system.data>
With regard to 64-bit systems, the class library of the Oracle client must also be 64-bit if it has not been tested for the time being.
Four. Summary
When deploying the program, if you encounter some exceptions that are not caught, the bottom runs out, this time you can install the C + + runtime, such as: Vc2008redist or vc2010redist.
Odp.net connection method, deployment problem Summary