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

Source: Internet
Author: User
Tags oracleconnection

Original address: http://www.cnblogs.com/gguozhenqian/p/4262813.html

There is a feature in the project need to get data from an Oracle database, this thought is very simple thing, the original SqlClient changed to OracleClient call, the result is far from the simple. 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. This aspect of the Internet search, too many articles, but also to test, choose, are almost bored. Finally found me a friend, he directly helped me to write a demo, I changed the connection string, the success of the connection, thank him very much. 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)
    1234567891011121314151617 using Oracle.ManagedDataAccess.Client;public static string ConnectOracle()        {            try            {                string connString = "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;";                OracleConnection con = new OracleConnection(connString);                               con.Open();                 return string.Empty;            }            catch (Exception ex)            {                return ex.ToString();            }        }

      
    It is so simple!!!

  3. Link string other notation:
    "Data source= (description= (address_list= (address= (PROTOCOL=TCP)
    (host=192.168.115.33) (port=1521))) (Connect_data= (service_name= Testdemo)));
    User id=oracle_test; Password=oracle ";

additional Help Documentation:

Http://www.cnblogs.com/yjmyzz/archive/2013/11/01/3400999.html
Http://www.cnblogs.com/ly303550688/archive/2013/01/31/2887104.html

Http://www.cnblogs.com/greenerycn/archive/2010/06/05/1751938.html

(GO) C # Connect to Oracle database (directly referencing DLLs)

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.