Using ODP.NET Client Provider in a Simple Application

The following is a simple C# application that connects to Oracle Database and displays its version number before disconnecting:

// C#
 
using System; 
using Oracle.DataAccess.Client;
 
class Sample
{
  static void Main()
  { 
    // Connect to Oracle
    string constr = "User Id=scott;Password=tiger;Data Source=oracle";
    OracleConnection con = new OracleConnection(constr);
    con.Open();
 
    // Display Version Number
    Console.WriteLine("Connected to Oracle " + con.ServerVersion); 
 
    // Close and Dispose OracleConnection
    con.Close();
    con.Dispose();
  }
}

Note:

Additional samples are provided in the ORACLE_BASE\ORACLE_HOME\ODP.NET\Samples directory.