OracleConnection is throwing empty exception

人盡茶涼 提交于 2019-12-18 07:07:09

问题


I'm trying to connect to my Oracle Database from my new PC. I've just installed Visual Studio and the ODAC. But when I try to do a simple connect Im getting an exception with an empty message, empty source, empty number, just with the error code which is -2147467259.

OracleConnection Prueba;
Prueba = new OracleConnection("Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=XXX.XXX.XXX.XXX)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=XXXX)));User Id=XXX;Password=XXX;Pooling=true;Max Pool Size=10;Min Pool Size=1");
Prueba.Open();

Exception Details
This is the Exception.ToString() code:

"Oracle.DataAccess.Client.OracleException at Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, String procedure)
at Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, Object src)
at Oracle.DataAccess.Client.OracleConnection.Open()
at OracleConnectionS.Program.Main(String[] args) in C:\Users\Simetri\Documents\Visual Studio 2010\Projects\OracleConnection\OracleConnection\Program.cs:line 19"

Any idea about why could this be happening?

UPDATE

If I run visual studio as Administrator I dont get the exception and I can connect to the database just fine.

I tried giving FULL CONTROL permission to the Oracle Directory C:\Oracle. But if I run Visual Studio in a normal way (not as administrator) I keep getting the exception.

Background Info
- I'm using Windows 7 64 bit
- Visual Studio 2010
- I can connect just find with SQL*PLUS


回答1:


So after installing all sort of versions of ODAC and searching to every single post related to this.

At the end Clean Install of the 32bit version was the solution.

  • First you need to unistall all your other oracle client you have ever installed.
  • After that, look for any ODAC version you want (latest if posible) but be sure to download the 32 bit version.

WHY?

Well is something related to the version in which Visual Studio is developed in. If you are developing a console application you will have not problem with the client version, but if you are using a web project then you definitely need the 32 bit version.

  • Finally be sure that all of your projects in visual studio the target platform is "32 bit"
  • and reference the new Oracle.DataAccess.dll that you have just installed



回答2:


Please try re-formatting your connection string into this form and see how it works

<add name="LoisDataAccess" connectionString="Data Source=LOISPRD;Persist Security Info=True;User ID=ABC;Password=DEF" providerName="System.Data.OracleClient" />



回答3:


If the client you are using is an "Instant Client" then you might be better off by copying some Oracle-DLLs into your solution - for a walktrhough see this.

IF possible I would recommend to use a different .NET provider... in my experience most commercial ones are much less problematic than the Oracle .NET provider - see here on SO.



来源:https://stackoverflow.com/questions/12460384/oracleconnection-is-throwing-empty-exception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!