-4

Currently I'm using the following method to get data from Oracle database and return it to DataTable:

private static DataTable OraSelect(string cmdString)
{
    string conString = ConfigurationManager.AppSettings["dbconnection"];
    OracleConnection oraCon = new OracleConnection(conString);
    OracleCommand oraCmd = new OracleCommand(cmdString, oraCon);
    OracleDataAdapter oraDA = new OracleDataAdapter(oraCmd.CommandText, oraCon);
    DataTable dt = new DataTable();
    oraCon.Open();
    oraDA.Fill(dt);
    oraCon.Close();
    return dt;
}

Visual Studio displays the following warning: "OracleConnection has been deprecated."

I think that's not the best way to do this. Could you give me some examples about how to get data from an Oracle database with a better method?

mabu
  • 286
  • 8
  • 26

1 Answers1

1

Have you seen MSDN Document as it clearly says in the class definiton

[ObsoleteAttribute("OracleConnection has been deprecated. http://go.microsoft.com/fwlink/?LinkID=144260", 
    false)]
public sealed class OracleConnection : DbConnection, ICloneable

Follow the link mentioned in attribute constructor parameter (Oracle and ADO.NET)

You should rather use the specific Data provider from Oracle

An Example: Connecting to Oracle Database through C#?

Community
  • 1
  • 1
Rahul
  • 76,197
  • 13
  • 71
  • 125