C # Remote connection to Oracle database (no client installed)

Source: Internet
Author: User
Tags creative commons attribution


This article was created by Jing and licensed under the Creative Commons Attribution-Share 3.0 Chinese mainland license agreement in the same way. Welcome reprint, but without the consent of the author must retain this paragraph, and in the article page obvious location to the original link.

Objective
Due to work requirements, data is now required to be obtained from a remote Oracle database. I began to think that can be directly remote, try to unexpectedly not, the hint "System.Data.OracleClient need Oracle client software 8.1.7 or later." ”。 The company's request is not to install the client, can not have to look for other options.

Instant Oracle
Good luck, really. Find a usable solution that is instant Oracle.
See http://www.oracle.com/technetwork/database/features/oci/index.html for an Introduction to instant Oracle.

Download Instant Oracle
Instant Oracle's: http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html.
Please select the download according to the operating system and the Oracle version of the server, download the account number, register it on the line.
My system is Windows Server 2003, select the Windows (32-bit) version. Since the remote server is loaded with Oracle 10g, I chose version 10.2.0.5 's basic package, 33.2M. For other basic Lite, JDBC Supplement, Sql*plus, SDK, and ODBC packages, interested friends can do their own research.


Installing Instant Oracle
In fact, do not need to install, decompression can be , do not rename to see the individual. This is to say, wait for a plsql test. I will unzip the instantclient_10_2 renamed to Oracleinstantclient_10_2, copy to the F packing directory.

Plsql Developer
If you need to install Plsql Developer, follow the steps set.
1. Create a new two directory in the F:\OracleInstantClient_10_2 directory, with a level of network\admin. Then, in a new Notepad, rename to Tnsnames.ora, open and enter the configuration. The host, PORT, service_name to their own content, as for the first line of the ORCL is related to the time of login, written as ABC or anything, but the database also has to fill in the ABC.

ORCL =  (DESCRIPTION = (    address_list = (      ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.0.60) (PORT = 1521))    
     (Connect_data =      (service_name = ORCL)    )  )

2. Set environment variables (user variables, environment variables, advanced, "Properties", right-click on my Computer), create a new user variable, variable name nls_lang, variable value simplified Chinese_china. ZHS16GBK.

3. Configure Plsql Developer. Tools->preferences->oracle->connection, set Oracle home to F:\oracleinstantclient_10_2,oci library for F:\ Oracleinstantclient_10_2\oci.dll.
4. Restart Plsql Developer, log in.

Remotely connect to Oracle
Description : The above environment variables, configuration are for Plsql Developer service, simple remote Oracle does not need to do those operations, only need to copy 4 DLLs into the project.

    • OCI Instant Client Data Shared Library
      • Oraociei10.dll (Basic version)
    • Client Code Library
      • Oci.dll
    • Security Library
      • Orannzsbb10.dll
    • OCCI Library
      • Oraocci10.dll

1. Create a new Windows Forms application and create a new form named Form1.
2. Refer to System.Data.OracleClient.
3. Copy Oci.dll, Orannzsbb10.dll, Oraocci10.dll, Oraociei10.dll to the project, in the same class as the form. Then set the 4 DLL file properties "Copy to Output directory" to " copy if newer ".
4. Remote connection string, please change to your own: Data source= (description= (address= (protocol=tcp) (host=192.168.0.60) (port=1521)) (Connect_data= ( (SID=ORCL))); User Id=youruid; Password=yourpwd;
5. The rest of the oracleconnection or something to solve it yourself.

Appendix
Instant Oracle Using C # by Paul Groetzner http://www.oracle.com/technetwork/database/features/instant-client/ Index-097480.html

C # Remote connection to Oracle database (no client installed)

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.