In the. Net project, the Oracle database configuration is linked through ODAC, And the odacoracle

Source: Internet
Author: User
Tags dotnet oracleconnection

In the. Net project, the Oracle database configuration is linked through ODAC, And the odacoracle

 

In the. Net project, use ODAC to link Oracle Database configurations

I. Development Environment

1. ODAC connection method

ODAC directly uses Oracle to call the interface (OCI ). OCI is an application interface that allows application developers to access the Oracle data server using a third-party development language and control the execution status of all SQL statements.

2. advantages of using ODAC

Use the Net option of ODAC instead of installing the Oracle client on the client to connect to Oracle. in this case, ODAC only needs the support of the TCP/IP protocol to create a real and minimal database application.

 

3. Steps for using ODAC

1) download the ODAC support plug-in from the official website

64 address: http://www.oracle.com/cn/solutions/midsize/index-090165.html

32 address: http://www.oracle.com/technetwork/topics/dotnet/utilsoft-086879.html

2) Add the following basic dependency references to the project:

Oci. dll, ociw32.dll, orannzentr11, orannzmcs11, orannzsbb11, oraocci11, oraociei11, orasql11.dll, volume (the second-level directory under the path of the ODAC installer)

3) Add a key reference after testing, regardless of 32-bit or 64-bit.

Oracle. DataAccess. dll (the relative path is in product \ 11.2.0 \ client_1 \ odp.net \ bin \ 2.x)

4) used in the project

In the project, using Oracle. DataAccess. Client calls the provided API to access oracle;

5) test instances

public void connByOracleClient()    {        string connString = @"user id=XXXXpassword=XXXX;Data Source=(DESCRIPTION ="    + "(ADDRESS = (PROTOCOL = TCP)(HOST = XX.xx.xx.xx)(PORT = 1521))"   + " (CONNECT_DATA ="     + " (SERVER = DEDICATED)"     + " (SERVICE_NAME = xx)"    + "))";        OracleConnection conn = new OracleConnection(connString);        conn.Open();        string sql = "select * from xx";         OracleCommand comm = new OracleCommand(sql, conn);        OracleDataReader rdr = comm.ExecuteReader();        while (rdr.Read())        {            string s = rdr.GetString(5);        }


6) Test Results

The link is successful and the data can be read. Everything is normal.

Ii. Server deployment and Configuration

1. Download The ODAC support installation package corresponding to the server from the official website

Download the ODAC support plug-in from the official website

64 address: http://www.oracle.com/cn/solutions/midsize/index-090165.html

32 address: http://www.oracle.com/technetwork/topics/dotnet/utilsoft-086879.html

2. Decompress odac.zip for installation.

Click setup.exe In the first-level directory to install it. click Next. (For installation details, see my blog http://blog.csdn.net/wangshuai6707/article/details/44788569)

3. Replace the ODAC reference used by the development environment in the project.

Oracle. DataAccess. dll (the program installation path is in product \ 11.2.0 \ client_1 \ odp.net \ bin \ 2.x)

 

 

 

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.