Sharpeye500 Sharpeye500 - 10 months ago 121
ASP.NET (C#) Question

Oracle connection open error when connecting from .NET code

I am getting this error(I am using Oracle.DataAccess dll):


(Oracle.DataAccess.Client.OracleException).DataSource threw an exception of type 'System.NullReferenceException'

StackTrace :

at Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32
errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx*
pOpoSqlValCtx, Object src, String procedure, Boolean bCheck, Int32
at Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode,
OracleConnection conn, IntPtr opsErrCtx, Object src)
at Oracle.DataAccess.Client.OracleConnection.Open()


using (OracleConnection conn = new OracleConnection(ConfigurationManager.ConnectionStrings["myConnection"].ConnectionString))
using (OracleCommand cmd = conn.CreateCommand())
cmd.CommandText = "<<Procedure Name>>";
cmd.Parameters.Add("v_cur", OracleDbType.RefCursor).Direction = ParameterDirection.Output;

conn.Open(); --line throws exception
using (OracleDataReader reader = cmd.ExecuteReader())
while (reader.Read())
retVal = reader["VALUE"].ToString();

Any inputs will be helpful? thanks.

Answer Source

One thing you can try if you have not, is to run the managed (Oracle.ManagedDataAccess.dll) version of the DLL instead of the non managed, I have found that it fixes some of my weird oracle connection issues. The managed version is self contained, does not depend on Oracle client and it works on 32 and 64 bit seamlessly