In the. Net project, use ODAC to link Oracle Database configurations
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)