Connect to Oracle Database

I try to connect to an Oracle database, but when the code executes the line:

con = new OracleConnection(oradb); 

He gives this error. "The program cannot start because oraons.dll is missing on your computer. Try reinstalling the program to fix this problem." I installed ODP for .net on my computer from the next site http://www.oracle.com/technetwork/topics/dotnet/index-085163.html and referenced Oracle.DataAccess.

I also checked the installed folder and I see the oraons dll in the folder. Here is the code:

 class OracleDatabase { OracleConnection con; public void ConnectToOracleDb() { string oradb = getConnectionString("host", 1521, "sid", "user", "pass"); try { con = new OracleConnection(oradb); con.Open(); Console.WriteLine("Connected to Oracle" + con.ServerVersion); } catch { Console.WriteLine("Could not connect to FLX"); } } private static string getConnectionString(string databaseIP, int databasePort, string databaseSID, string databaseUN, string databasePW) { return string.Format( "Data Source=(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = {0})(PORT = {1}))(CONNECT_DATA =(SID = {2})));" + "Persist Security Info=True;User ID={3};Password={4}", databaseIP, databasePort, databaseSID, databaseUN, databasePW ); } } 

Why can't I connect any offers?

+7
c # database oracle11g database-connection
source share
3 answers

I ended up referencing ManagedDataAccess.Client, not just Data.Access.Client, and it worked.

+3
source share

PATH configuration is not required. I solved the same problem with a copy of the oraons.dll folder in dhe ORACLE_HOME\bin , after which the installation works.

There is a difference between installing Oracle through the installer and the xcopy operation. I do not understand why. Both installations had the same registry entry:

 HKEY_LOCAL_MACHINE\SOFTWARE\Oracle\ODP.NET\4.112.4.0\DllPath 

and DllPath points to the BIN ORACLE_HOME folder. This means that setting PATH to the BIN ORACLE_HOME folder does not help. Additional PATH help for the ORACLE_HOME client. I think this is not necessary. Just copy oraons.dll in the BIN .

+4
source share

I was getting this error in my test project. The problem was that I was opening Visual Studio from the command line that had the old PATH. After the opening, everything is fresh, it worked.

Check PATH from your code and make sure the oracle folder is in PATH.

+2
source share

All Articles