OracleConnection is throwing empty exception
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:UsersSimetriDocumentsVisual Studio 2010ProjectsOracleConnectionOracleConnectionProgram.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
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.
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.
请尝试将连接字符串重新格式化为此表单并查看其工作原理
<add name="LoisDataAccess" connectionString="Data Source=LOISPRD;Persist Security Info=True;User ID=ABC;Password=DEF" providerName="System.Data.OracleClient" />
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.
链接地址: http://www.djcxy.com/p/67184.html上一篇: C#