Odp.net connection method, deployment problem summary, odp.net deployment

Source: Internet
Author: User
Tags oracleconnection connectionstrings

Odp.net connection method, deployment problem summary, odp.net deployment

 

I. Summary
   

During C # development, you often need to operate the Oracle database. When deploying a program, you often need to follow the requirements of the system environment (32, 64 bit) and do not install the Oracle client, odp.net does not have a perfectly compatible class library and can be called by applications. Therefore, there are always various problems during deployment, which is a headache. Here, I will summarize the problems encountered in my work.

Ii. Outline of this Article
   

Connection Method

32-bit System

64-bit System

Oracle client installation-free

Summary

Iii. Main Content

 

Connection Method
   

C # connection to Oracle. I usually connect to Oracle through 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. You can call it directly. There is nothing to say. If you want to avoid installing the client, we will talk about it below.

  

 

64-bit environment

 

 

 

Add

  <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>

 

 

Free installation of the Oracle client:

Extract the class library files from five Oracle clients and put them in the program root directory, including oci. dll, Oracle. DataAccess. dll, orannzsbb11.dll, oraociei11.dll, and 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>
 

For 64-bit systems, the class library of the Oracle client must be 64-bit.

 

Iv. Summary
  

  

When you deploy a program, you can install the C ++ Runtime Library, such as vc2008redist or vc2010redist, if you encounter exceptions that cannot be captured and run at the underlying layer.


C # How to Use ODPnet to use the oracle connection pool

MyConn = new OracleConnection (s_ConnStr );
MyComm = new OracleCommand ();
MyConn. Open ();

You have to use ODP. NET. I don't know ..
In the preceding statements, a connection pool is created and a connection is created.
Zhao Yuanyuan [authoritative expert]

An error occurred while connecting to oracle with VS2008 after installing odpnet.

In your tnsnames, service_name = tjnscs

Why is SID = tjnscs used in the program?

Also changed to service_name = tjnscs, that is:
OracleConnection con = new OracleConnection ("Data Source = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.0.250) (PORT = 1521 ))) (CONNECT_DATA = (SERVICE_NAME = tjnscs); User ID = tjnscs; Password = SCS; "); or:
OracleConnection con = new OracleConnection ("Data Source = TJNSCS; User ID = tjnscs; Password = SCS ;");
Please accept it if you are satisfied!


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.