C # Connect to Oracle Database (direct reference DLL usage)

Source: Internet
Author: User
Tags oracleconnection

There is a feature in the project that needs to get data from an Oracle database, which was thought to be very simple, and changed the original SqlClient into a OracleClient call.

The result is far less simple than you think. There are a lot of needs to install Oracle client, just the project is very urgent, the company also has no Oracle environment, can make me nasty. After searching this area online,

Too many articles, but also to continue to test, choice, are almost bored. Finally found me a friend, he directly helped me to write a demo, I changed the connection string,

I was very grateful to him for the successful connection. This DLL is actually provided by Oracle for C #, and it can be downloaded to the official (but it's cumbersome to find).

Here I will share this program and DLL to everyone.

Operation Steps:

    1. DLL after downloading and referencing
      : Oracle.ManagedDataAccess.zip
      After downloading, place the Oracle.ManagedDataAccess.dll in your project and then reference

    2. Direct invocation (connstring changes to its own connection string)
      1 usingOracle.ManagedDataAccess.Client;2  3  Public Static stringconnectoracle ()4         {5             Try6             {7                 stringConnString ="Data source= (description= (address= (protocol=tcp) (host=130.147.246.144) (port=1521)) (Connect_data= (SERVICE_ (NAME=ECMS))); Persist Security info=true; User Id=system; PASSWORD=SERVICE01;";8OracleConnection con =NewOracleConnection (connstring);9                 Ten con. Open (); One                 return string. Empty; A             } -             Catch(Exception ex) -             { the                 returnEx. ToString (); -             } -}

      This essay copyright belongs to: https://www.cnblogs.com/gguozhenqian/p/4262813.html

    3. Hereby thank

C # Connect to Oracle Database (direct reference DLL usage)

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.