Connect to an Oracle server : Oracle : Database C# Source Code


Custom Search

C# Source Code » Database » Oracle »

 

Connect to an Oracle server








    

using System;
using System.Data;
using System.Data.OracleClient;

class OracleConnect
{
   static void Main() 
   {
      string connString = @"server = myServer;uid = scott;password = tiger;";

      OracleConnection conn = new OracleConnection(connString);

      try 
      {
         conn.Open();
         Console.WriteLine("Connection opened.");

         Console.WriteLine("Connection Properties:");   
         Console.WriteLine("\tConnection String: {0}", conn.ConnectionString);    
         Console.WriteLine("\tServerVersion: {0}", conn.ServerVersion);
         Console.WriteLine("\tState: {0}", conn.State);
      } catch (OracleException e) {
         Console.WriteLine("Error: " + e);  
      } finally {
         conn.Close();
         Console.WriteLine("Connection closed.");
      }
   }
}



           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Database
» Oracle