Use Odp.net to access Oracle (. NET How to access Oracle) detailed "Go"

Source: Internet
Author: User

Http://www.cnblogs.com/qinpengming/archive/2013/06/08/3127346.html

1, what is ODF. NE,? Oracle data Provider is specifically written for. NET (odp.net), one for the Oracle Access API for Microsoft. NET environments.

Detailed explanation http://www.oracle.com/technetwork/cn/testcontent/o23odp-084525-zhs.html for the official code, no longer exists!

Odp. NET you do not need to install Oracle, do not need to configure the Oracle.key file, do not need to configure the Tnsnames.ora file does not need to configure environment variables; complete idiot without installing an Oracle database or

Clients such as any Oracle products machine to access the Oracle database!

Here is a detailed explanation of how odp.net data operations for Oracle "can be completed, curd (additions and deletions)"

Step one : Get the class library file that supports the database connection: How doesOracle.DataAccess.dll get it?

To the official website to the corresponding version http://www.oracle.com/technetwork/cn/topics/dotnet/index-088718-zhs.html

to run 64-bit. NET program, you must use the 64-bit odp.net, to run 32-bit. NET programs, you must use 32-bit odp.net,Finally, the odp.net32 bits and 64 bits are given:64 Guestshttp://www.oracle.com/technetwork/database/windows/downloads/index-090165.html32 Guestshttp://www.oracle.com/technetwork/database/windows/downloads/index-101290.html

After downloading the installation will appear in your installation directory \dp.net\bin\2.x (Figure 1) This Oracle.DataAccess.dll, copy it to your solution under the reference

Figure 1

By the way, click Oraprovcfg.exe automatically configures environment variables (Figure 2)

Figure 2

Successfully obtain the required DLL files, some people have to go to a file to unzip, to configure, I do not want to see, if necessary, this is a detailed configuration steps

http://blog.csdn.net/Sunlihgt_love/article/details/5423926

Step two : Before you use it formally, you need to add a reference to your project:

Oracle.DataAccess.Client Set the database connection and so on common functions,

Oracle.DataAccess.Types Setting some data types for Oracle customization

Step three : illustrative examples

Information such as the following database is provided

Database server address: 192.168.10.20
Library Name: 44410g242
Account Number: 44bikll
Password: 487gf,.q

The string that connects to Oracle is like this (2 ways to provide my test)

String constring = "Data source= (description= (address= (protocol=TCP) (host=192.168.10.20) (port= 1521)) "+
(Connect_data= (SERVER = dedicated) (service_name = 44410g242)); User id=44bikll; password=487gf,.q; ";

String constring = "Data source= (description= (address= (protocol=TCP) (host=192.168.10.20) (port= 1521)) "+
(Connect_data= (sid=44410g242)); User Id=44bikll; password=487gf,.q; ";
Write connection string above 2 method connections can be, or can be placed in Web. config.

The above connection protocol TCP and port 1521 are the default, without modification, such as the port is occupied needs to be changed.

2 Tables Tblocklog and Tbaccount are involved in this case

View Code

Show Results:

1. Establishing a database
             Create a table named Oracletypestable
           "CREATE table Oracletypestable (MyVarchar2 varchar2), MyNumber number (28,4) Primary key,mydate            Date,myraw RAW (255)) ";
           inserts a row of data
          "INSERT INTO Oracletypestable values (' Test ', 4,to_date (' 2000-01-11

Description of other operations: (Instruction for use: http://www.oracle.com/technetwork/cn/testcontent/o23odp-084525-zhs.html)

Note:

1, the SQL statement in the case is still a little different from MSSQL;

2, statistics if not get statistics of the data will be an error, this is why I add if (rdr. Getoraclevalue (0). ToString () = = "NULL")//Prevent null

3,webservice don't know why he has a distinction between the case of a user name.

Step four : Deployment notes

When deploying to the real server, you also follow the steps in step one to install the client odp.net file, click the Execute EXE file to automatically configure environment variables to see if the installation is successful.

Note that the version is consistent, this is the key to running your program, open cmd, execute: C:\Documents and settings\administrator>Sqlplus/nolog can know the version

My results:

Here are a few of the issues associated with the version of the article---version of the ODP. NET development and deployment related issues


Http://www.cnblogs.com/yjmyzz/archive/2011/04/19/2020793.html

Http://www.cnblogs.com/codingsilence/archive/2011/07/14/2146497.html

Http://blog.chinaunix.net/uid-20049824-id-1980177.html

supplementing which 11.2.0.3.50 beta will be more appropriate for fast operation of Oracle, but requires support from Win7 and. NET Framework 4, the general enterprise estimate has not yet put Win7 as a server!

Http://www.oracle.com/technetwork/database/windows/downloads/odpmbetainstall-1696475.html

This http://www.bitscn.com/pdb/oracle/200904/160401.html Instant client on-line installs Oracle clients in bulk-

The installation configuration also requires that you copy the Oracle.key file from the machine on which you have installed Oracle and configure environment variables.

Just so much, I hope to help you. , the following is the DLL for odp.net

Happy Dragon Boat Festival !

Diligence in the leisure journeys by chance destroyed in the following

Use Odp.net to access Oracle (. NET How to access Oracle) detailed "Go"

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.