简体   繁体   English

OracleConnection.Open上的NullreferenceException

[英]NullreferenceException on OracleConnection.Open

I am trying to connect to an Oracle Database with C#. 我正在尝试使用C#连接到Oracle数据库。 For that I am trying to use ODP.NET since I found out that this should be the best way to do it. 为此,我尝试使用ODP.NET,因为我发现这应该是最好的方法。

Sadly I am getting a NullReferenceException as soon as I try to open the connection. 可悲的是,当我尝试打开连接时,我立即收到NullReferenceException

Stack trace: 堆栈跟踪:

at Oracle.DataAccess.Client.OracleConnection.Open() 在Oracle.DataAccess.Client.OracleConnection.Open()

at odptest.MyAddin.Initialize() in C:\\ProgramData\\SRH Systems\\STARS\\Projects\\odptest\\MyAddin.cs:line 28 在odptest.MyAddin.Initialize()中的C:\\ ProgramData \\ SRH Systems \\ STARS \\ Projects \\ odptest \\ MyAddin.cs:第28行

And this is my code: 这是我的代码:

using (OracleConnection conn = new OracleConnection())
{
    try
    {
        conn.ConnectionString = constr;
        conn.Open();
    }
    catch (Exception ex)
    {
    }
}

I am using the latest version of odp.net from here: http://www.oracle.com/technetwork/topics/dotnet/utilsoft-086879.html 我正在从这里使用odp.net的最新版本: http : //www.oracle.com/technetwork/topics/dotnet/utilsoft-086879.html

I am realy confused, and even so I found some posts with the same problem, there was no solution offerd. 我真的很困惑,即使如此,我还是发现了一些存在相同问题的帖子,但没有提供解决方案。 I just need a simple SQL query from the DataBase and I don't know what the problem is. 我只需要从数据库中进行一个简单的SQL查询,就不知道问题出在哪里。

If Login Id and Password is correct, re-start IIS. 如果登录ID和密码正确,请重新启动IIS。 You might have re-started database service. 您可能已经重新启动了数据库服务。

好的,我不知道我到底做了什么,但是我重新安装了Oracle Client 12c,现在按预期建立了连接。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 OracleConnection.Open()在ASP.NET中不起作用 - OracleConnection.Open() not working in ASP.NET 如果连接已经打开,可以调用OracleConnection.Open()吗? - Is it okay to call OracleConnection.Open() if the connection is already open? OracleConnection.Open 抛出 ORA-12541 TNS 没有监听器 - OracleConnection.Open is throwing ORA-12541 TNS no listener ODP.Net OracleConnection.Open冷启动很慢 - ODP.Net OracleConnection.Open cold start very slow 尝试连接到Oracle数据库时发生OracleConnection.Open()AccessViolationException - OracleConnection.Open() AccessViolationException when try to connect to oracle database OracleClient,间歇性连接问题:应用程序在OracleConnection.Open()上挂起,没有超时,没有引发异常 - OracleClient, intermittent connection issue: app hangs on OracleConnection.Open(), no timeout, no exception thrown 为什么将 Oracle DB 从 11g 升级到 19c 后 OracleConnection.Open() 的实例会抛出错误? - Why the Instance of OracleConnection.Open() throws an error after upgrading the Oracle DB from 11g to 19c? Oracle.DataAccess.Client.OracleConnection.Open()引发NullReferenceException - Oracle.DataAccess.Client.OracleConnection.Open() throws NullReferenceException 使用 OracleConnection.Open() 时出错 ORA-00303:网络库:名称-值语法错误 ODP.NET 托管 dll - Error when using OracleConnection.Open() ORA-00303: Network Library: Name-Value syntax error ODP.NET managed dll 当使用64位的NullReferenceException“新的OracleConnection”? - NullReferenceException when using “new oracleConnection” in x64?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM