从.NET代码连接时,Oracle连接打开错误 [英] Oracle connection open error when connecting from .NET code

查看:173
本文介绍了从.NET代码连接时,Oracle连接打开错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到此错误(我正在使用Oracle.DataAccess dll):

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

{Oracle.DataAccess.Client.OracleConnection}

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

StackTrace:

StackTrace :

at Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32
errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx*
pOpoSqlValCtx, Object src, String procedure, Boolean bCheck, Int32
isRecoverable)
   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();
                        }
                        reader.Close();
                    }
                }
            }

任何输入都会有所帮助吗?谢谢.

Any inputs will be helpful? thanks.

推荐答案

如果没有,您可以尝试的一件事是运行DLL的托管(Oracle.ManagedDataAccess.dll)版本,而不是非托管版本,已经发现它解决了我一些奇怪的oracle连接问题.托管版本是独立的,不依赖于Oracle客户端,并且可以无缝地在32位和64位上工作

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

这篇关于从.NET代码连接时,Oracle连接打开错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆