0

I am able to get a successful connection to an Oracle database as can be seen in the image below:

enter image description here

However, when I try to connect and make a query through code, I get the error:

"

ERROR:  Message:System.TypeInitializationException: The type initializer for 'Oracle.DataAccess.Client.OracleConnection' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'OraOps12.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
   at Oracle.DataAccess.Client.OpsInit.CheckVersionCompatibility(String version)
   at Oracle.DataAccess.Client.OracleInit.Initialize()
   at Oracle.DataAccess.Client.OracleConnection..cctor()
   --- End of inner exception stack trace ---
   at Oracle.DataAccess.Client.OracleConnection..ctor(String connectionString)

"

on the line for Oracle connection:

string oradb = "Data Source=" + oracleDataSource + ";User Id=" + oracleUserID + ";Password=" + oraclePassword + ";";

OracleConnection conn = new OracleConnection(oradb); <----error thrown here

The credentials are the same as enetered in the server explorer

How do I fix this?

Kinyanjui Kamau
  • 1,890
  • 10
  • 55
  • 95
  • Post the full exception text, not just the message part. The full exception will tell you what's wrong. Most likely the error is in an inner exception. You can get the full exception text easily with just `Exception.ToString()` or by clicking on `Copy Details` in the exception popup while debugging – Panagiotis Kanavos Nov 23 '22 at 09:53
  • 1
    I assume the connection wizard uses a different driver/provider to establish the connection, see http://stackoverflow.com/questions/34803106/how-to-connect-to-oracle-11-database-from-net/34805999#34805999 – Wernfried Domscheit Nov 23 '22 at 09:54

1 Answers1

0

There can be several reasons. Most common are:

  • mismatch of 32bit vs. 64bit
  • Version mismatch between Oracle.DataAccess and Oracle client or Oracle client is not installed

See more details at The provider is not compatible with the version of Oracle client

Wernfried Domscheit
  • 54,457
  • 9
  • 76
  • 110