OracleConnection is throwing empty exception
Asked Answered
C

3

2

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

Commissary answered 17/9, 2012 at 13:34 Comment(4)
Have you tried connecting outside of VS, e.g. using TNSPing and then with SQL Developer?Gnathous
@Commissary How did you correct it?Gujranwala
@Laggel: Please show the output of ex.ToString()Bombay
@DanielHilgarth "Oracle.DataAccess.Client.OracleException at Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, String procedure)\r\n at Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, Object src)\r\n at Oracle.DataAccess.Client.OracleConnection.Open()\r\n at OracleConnectionS.Program.Main(String[] args) in C:\Users\Simetri\Documents\Visual Studio 2010\Projects\OracleConnection\OracleConnection\Program.cs:line 19"Commissary
C
4

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
Commissary answered 19/12, 2013 at 14:59 Comment(0)
A
0

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" />
Agnostic answered 17/9, 2012 at 14:7 Comment(2)
I'm not using the client of Microsoft. Im using the the client of Oracle using Oracle.DataAccess.Client;Commissary
Ok, so the providername would be different. I was trying to suggested that if you trim out the unnecessary stuff from your connection string it could fix your issue. All you need should be a datasource and a username/passwordAgnostic
A
0

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.

Allhallows answered 17/9, 2012 at 14:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.