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:
- dll after downloading and referencing
: Oracle.ManagedDataAccess.zip
After downloading, Place Oracle.ManagedDataAccess.dll in your project and reference
- direct call (connstring to own connection string)
using Oracle.manageddataaccess.client;public static string connectoracle () {try {s Tring 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 (); }}
is so simple!!!
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
C # Connect to Oracle Database (direct reference DLL usage)