Oracle connection string for C# : Oracle « Database « C# / C Sharp

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";


    OleDbDataReader myOleDbDataReader = myOleDbCommand.ExecuteReader();


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


Related examples in the same category

1.How to use an OleDbConnection object to connect to an Oracle database
2.Connect to an Oracle server
3.Static Helper for executing SQL statements against Oracle Requires the ODP.NET provider