Using ODP.NET in a Simple Application
The following is a very simple C# application that connects to an Oracle database and displays its version number before disconnecting.
using System; 
using Oracle.DataAccess.Client; 
class Example 
{ 
  OracleConnection con; 
  void Connect() 
  { 
    con = new OracleConnection(); 
    con.ConnectionString = "User Id=scott;Password=tiger;Data Source=oracle"; 
    con.Open(); 
    Console.WriteLine("Connected to Oracle" + con.ServerVersion); 
  } 
  void Close() 
  { 
    con.Close(); 
    con.Dispose(); 
  } 
  
  static void Main() 
  { 
    Example example = new Example(); 
    example.Connect(); 
    example.Close(); 
  } 
} 
| 
 Note: 
Additional samples are provided in the ORACLE_BASE\ORACLE_HOME\ODP.NET\Samples directory. |