How to establish a OracleConnection without making use of the obsolete OracleConnection Class

SighteD picture SighteD · Jun 9, 2016 · Viewed 26.2k times · Source

What's the 'new' way of establishing a OraConnection? Microsoft defines several classes as obsolete.

https://msdn.microsoft.com/en-us/library/system.data.oracleclient.aspx

I used to make use of something along those lines:

 string queryString = 
    "INSERT INTO Dept (DeptNo, Dname, Loc) values (50, 'TECHNOLOGY', 'DENVER')";
using (OracleConnection connection = new OracleConnection(connectionString))
{
    OracleCommand command = new OracleCommand(queryString);
    command.Connection = connection;
    try
    {
        connection.Open();
        command.ExecuteNonQuery();
    }
    catch (Exception ex)
    {
        Console.WriteLine(ex.Message);
    }

However all those Classes seem to be deprecated.

Answer

Werner Bisschoff picture Werner Bisschoff · Jun 9, 2016

Yes the System.Data.OracleClient is Obsolete.

Download the latest Oracle Client (ODP.Net) as per link below:

http://www.oracle.com/technetwork/topics/dotnet/index-085163.html

and reference the following namespace in your code

using Oracle.DataAccess.Client;