Oracle connection string for C# : Oracle : Database C# Source Code


Custom Search

C# Source Code » Database » Oracle »

 

Oracle connection string for C#








    


using System;
using System.Data;
using System.Data.OleDb;

class OleDbConnectionOracle
{
  public static void Main()
  {
    string connectionString = "provider=MSDAORA;data source=ORCL;user id=SCOTT;password=TIGER";
    OleDbConnection myOleDbConnection = new OleDbConnection(connectionString);

    OleDbCommand myOleDbCommand = myOleDbConnection.CreateCommand();

    myOleDbCommand.CommandText = "SELECT empno, ename, sal FROM emp WHERE empno = 7369";

    myOleDbConnection.Open();

    OleDbDataReader myOleDbDataReader = myOleDbCommand.ExecuteReader();

    myOleDbDataReader.Read();

    Console.WriteLine("myOleDbDataReader[\" empno\"] = " + myOleDbDataReader["empno"]);
    Console.WriteLine("myOleDbDataReader[\" ename\"] = " + myOleDbDataReader["ename"]);
    Console.WriteLine("myOleDbDataReader[\" sal\"] = " + myOleDbDataReader["sal"]);

    myOleDbDataReader.Close();
    myOleDbConnection.Close();
  }
}
           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Database
» Oracle