[英]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.