There is a feature in the project that needs to get data from an Oracle database, and it's a simple thing to replace the original SqlClient with a OracleClient call,
The result is far less simple than you think. There is a lot of need to install Oracle clients, the project is very urgent, the company also does not have Oracle environment, can make me nasty. After searching this area on the Internet,
Too many articles, but also to continue to test, choice, are quickly bored. Finally found a friend of mine, he directly helped me write a demo, I changed the connection string,
I was so grateful to him for the successful connection. This DLL is actually specifically provided by Oracle for C #, and can be downloaded to the official (but cumbersome to find).
Here I will share this program and DLL to everyone.
Action step: DLL download and reference download address: Oracle.ManagedDataAccess.zip After downloading, place the Oracle.ManagedDataAccess.dll in your own project, and then reference
Direct call (connstring to its own connection string)
A reference to the "Oracle.ManagedDataAccess.dll" class public
bool Connect (string hostaddress, string servername, String uid is added to the project. string pwd)
{
string connstring = ' Data source= (description= (address= (protocol=tcp) (host= "+ hostaddress +") ( port=1521)) (Connect_data= (service_name= "+ servername +"))); Persist Security info=true; User id= "+ uid +"; Password= "+ pwd +"; ";
OracleConnection conn = new OracleConnection (connstring);
Conn. Open ();
IF (Conn. state = = ConnectionState.Open)
{
Conn. Close ();
MessageBox.Show (Conn. State.tostring ());
return true;
}
else
{return
false;
}
}
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