Skip Headers
Oracle® Data Provider for .NET Developer's Guide
10g Release 2 (10.2.0.2)
B28089-01
  Go To Table Of Contents
Contents
Go To Index
Index

Previous
Previous
 
Next
Next
 

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.