Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 723
SighteD Avatar asked Jun 09 '16 13:06

SighteD


People also ask

What can I use instead of OracleConnection?

OracleClient as per the standard support policy for . Net Framework 4.0.

What is OracleConnection?

An OracleConnection object represents a unique connection to an Oracle database. In the case of a client/server database system, it is equivalent to a network connection to the server.

What is System data OracleClient?

Data. OracleClient is a Microsoft . NET data provider allowing you to connect to an Oracle database. The provider is deprecated and it should not be used - Oracle and ADO.NET.

What is Oraclecommand?

ExecuteNonQuery Method (System. Data. OracleClient) Executes an SQL statement against the Connection and returns the number of rows affected.


1 Answers

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;
like image 71
Werner Bisschoff Avatar answered Oct 06 '22 00:10

Werner Bisschoff