C # Connect to Oracle, install client free

Source: Internet
Author: User

The small partners who develop Oracle applications under the. NET Platform are sure to know that on the one hand, Oracle development and implementation is more complex than SQL Server to install Oracle clients (XCopy, extract related files themselves) On the other hand, compared to the Java platform is not as easy as JDBC, especially some new contacts with Oracle's small partners, face configuration Tns.ora, orahome, and so much some fear mood.

Initial Lushan

Now, it's all going to be the past. Following the earlier release of Oracle's beta version of Odp.net managed, the latest version has been released with 12c and can be downloaded by DLL Http://pan.baidu.com/s/1boDID4N. Corresponding to the coarse look, download the version of 64bit, downloaded after the completion of a few files.

A few words in a readme.htm, the familiar network folder is equivalent to a tnsnames and sqlnet template, managed also provides a document, the description is very few, mainly introduces some configuration and bug situation, the core is common GedDataAccess.dll This file, Oracle.ManagedDataAccess.Client.Configuration.Section.xsd this file to know is provided to the VS XML editor to provide smart hints, and then the inside also distinguish between X64 and X86 folder, one convenient is mainly distributed transaction Oracle.ManagedDataAccessDTC.dll different, the other is the bat file related commands are different.

If you are familiar with the previous odp.net oraprovcfg, then configure.bat inside the content is very well understood, this batch of work has done so few things, of which 2, 4, 5 is not necessarily:

1, the driver corresponding to the DB Factory register and add the configuration processor, in fact, in Machine.config added <section name= "Oracle.manageddataaccess.client" Type= "OracleInternal.Common.ODPMSectionHandler, Oracle.manageddataaccess, version=4.121.1.0, Culture=neutral, publickeytoken=89b483f429c47342 "/> and <add name=" odp.net, Managed Driver "invariant=" Oracle.ManagedDataAccess.Client "description=" Oracle Data Provider for. NET, Managed Driver "type=" Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.manageddataaccess, version=4.121.1.0, culture=neutral , publickeytoken=89b483f429c47342 "/> This allows the Oracle.ManagedDataAccess.Client driver and the Oracle.manageddataaccess.client configuration node to be identified in the next development and deployment (in fact, if a separate program configuration is also possible, it is important to note whether the GAC is used)

2. Add Odp.net Managed performance counter (performance Counter)

3. Add Oracle.ManagedDataAccess.dll to the GAC

4. Provide smart hints for configuring nodes in the VS development environment, in fact, to copy the previously mentioned Oracle.ManagedDataAccess.Client.Configuration.Section.xsd to the VS counterpart Directory

5. Add log records

6. Add VS development environment support for Oracle.ManagedDataAccess.dll references

Kind

VS Create a new project, reference Oracle.ManagedDataAccess.dll, start random code a few lines of the entry-level code ..., you can see, as Orale himself described, and the previous API is very small, the difference is that the namespace replaced by using Oracle.ManagedDataAccess.Client;

   1:              new OracleConnection ();
   2:              "user Id=his3;password=his3;data SOURCE=192.168.1.237/ORCL";
   3:              con. Open ();
   4:  
   5:              new OracleCommand ();
   6:              cmd.commandtype = System.Data.CommandType.Text;
   7:              "SELECT * from Gy_yonghuxx";
   8:              cmd. Connection = con;
   9:  
  :              new OracleDataAdapter ();
  One:              da. SelectCommand = cmd;
  :              new DataSet ();
  A:              da. Fill (DS);
  :  
  :              con. Close ();
  A:              da. Dispose ();
  :              cmd. Dispose ();
  :              con. Dispose ();

A good eye partner must be able to find out the special of ConnectionString, there are three ways to connect strings of characters:

A, TNS alias: "User Id=scott;password=tiger;data Source=sales", in this specific corresponding TNS file can be specified in the config file, Like my machine.config gave me a default of a <setting name= "tns_admin" value= "d:\installsoft\oracle\odp.net_managed121010\odp.net \managed\x64\. \.. \.. \network\admin "/>

b, connect descriptor: This way is to put a section of the TNS configuration to write in, compared to C is a bit of configurable items in full

  "User Id=scott;password=tiger;data source=" +      "(description= (address= (PROTOCOL=TCP) +" (      host=sales-server ) (port=1521)) (connect_data= "+     " (service_name=sales.us.acme.com))) "
C, easy Connect naming Method:protocol and some other options seem to have no place to configure the
  "User Id=scott;password=tiger;data source=//sales-server:1521/sales.us.acme.com"
Entity Framework Refactoring
   For projects that have already started or are ready to use the Entity Framework (the current version does not support code first), it is easy to be familiar with ADO, a total of three points to note
1. Provider=oracle.dataaccess.client in the connection string in the configuration file; Replace with Provider=oracle.manageddataaccess.client;provider
2. Provider= "Oracle.DataAccess.Client" in the edmx of the corresponding entity file is also replaced with provider= "Oracle.ManagedDataAccess.Client"
3, if the data type mapping has been configured (Oracle default type mapping a little pit dad), you need to add the red line below the
A probe into what

Performance testing I would like the official version of the Oracle has certainly done before the official, the test comparison is not professional after all, but a cursory look at the internal implementation of how much can be discerned, if seen before the Oracle-driven DLL (Mircrosoft, Oracle, Devert provided by the DLL) must know that it was previously dependent on Oci.dll this interface, the final implementation of the call is through P\invoke. is followed by Oracleconnect.open the last trace of the Oraclecommunication class, which has appeared in Soket, Socketstream and other objects, this time the managed version of the host is still relatively thorough, The individual feels that the performance should be more efficient than p\invoke.

DLL Download:

C # Connect to Oracle, install client free

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.