Share via


Unable to establish connection to Oracle db with the Oracle.DataAccess.dll version 2.112.1.0

Question

Monday, March 11, 2013 8:58 PM

Hi

I am uable to connect to Oracle Database 11g (version 2.112.1.0). Getting below error.

ServerVersion = 'connection.ServerVersion' threw an exception of type 'System.InvalidOperationException'

'((Oracle.DataAccess.Client.OracleException)($exception)).DataSource' threw an exception of type 'System.NullReferenceException'

Can any one help me on this ?

Here is the sample code.

class

Program

{

static void Main(string[] args)

{

String conStr = "Data Source=dbname;User ID=id;Password=pwd";

TestOracleConnection(conStr);

}

public static string TestOracleConnection(string _oraConnStr)

{

OracleConnection oc = null;

try

{

oc =

new OracleConnection(_oraConnStr);

oc.Open();

return "success";

}

catch (Exception _e)

{

return _e.Message;

}

finally

{

if (oc != null)

{

oc.Close();

oc.Dispose();

}

}

}

}

shravan

All replies (4)

Tuesday, March 12, 2013 9:09 AM

Hello,

Please, could you have a look at this link ?

http://www.connectionstrings.com/oracle#net-framework-data-provider-for-oracle

I am not a specialist of ORACLE but it is possible that you have forgottent to provide the vale for the Provider property of the connection string.

A little advice : always provide the value for Integrated Secutirity as it is always dangerous to rely on default values ( the default value is not a SQL Server authentification )

Have a nice day

PS : I know that there are forums on the ORACLE site but i have not tested it as it is necessary to register ( i prefer to use SQL Server on Windows operating systems ) but  i may provide you the related link if you are unable to get it ( i recognize that it is not evident to find it )

Mark Post as helpful if it provides any help.Otherwise,leave it as it is.


Tuesday, March 12, 2013 2:34 PM

Hi Normand,

Thanks for the reply.
I am able to connect to oracle with System.Data.OracleClient dll and get the data from Oracle database. But when i tried with Oracle.DataAccess.dll version 2.112.1.0, it is giving me above error.

shravan


Thursday, March 20, 2014 6:25 PM

I had the same problem crop up just recently.  I have no problem connecting to Oracle in the same app using different connection strings.  The Oracle DB is handled by another Team in my company.

I can connect via SqlPlus on the server, but the connection via .NET fails with the Version error (raises an exception).

serverversion threw an exception of type 'system.invalidoperationexception'

< addname="connOra"connectionString="Data Source=XYZ.WORLD;Persist Security Info=True;User ID=USER;Pooling=true;"providerName="System.Data.OracleClient"/>

Causing a simple data call to return nothing.


Wednesday, May 13, 2015 4:01 AM

Hi!

   Can anyone help answering this question? I am having the same problem, I have tried many different ways, but still the same error: 'connection.ServerVersion' threw an exception of type 'System.InvalidOperationException'.

Does it require necessary steps to download Oracle Data access component(ODTwithODAC121021) AND Oracle Database Client Software(instantclient_12_1)?

Thanks in advance!

SH.