Microsoft has deprecated System.Data.OracleClient, so here's a simple example of using the new ODP.NET Oracle.DataAccess.Client, with the following benefits: * Simple Xcopy deployment * No Oracle [instant] client installation needed * No TnsNames.Ora file needed Firstly, download the ~200mb ODP.Net from Oracle. Don't freak out, you won't need to redistribute *all* this with your app, just ~30megs worth. I used this version [link] but you'll probably want to get the latest version [link].

Grab Oracle.DataAccess.dll from: ODAC1110710beta.zip \ stage \ Components \ oracle.ntoledb.odp_net_2 \ 11.1.0.7.10 \ 1 \ DataFiles \ filegroup4.jar

Copy it into your project (For winforms: the same folder as your project's Program.cs; For Asp.net: the Bin folder). In Visual Studio, right click references and add the Oracle.DataAccess.dll.

Write some code like this in your app:

using Oracle.DataAccess.Client; // This goes up the top
...
string connstring =
  "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=myhost)(PORT=1527))" +
  "(CONNECT_DATA=(SID=mysid)));User Id=myuserid;Password=mypassword;";
using (OracleConnection conn = new OracleConnection(connstring))
{
  conn.Open();
  string sql = "select distinct owner from sys.all_objects order by owner";
  using (OracleCommand comm = new OracleCommand(sql, conn))
  {
    using (OracleDataReader rdr = comm.ExecuteReader())
    {
      while (rdr.Read())
      {
        Console.WriteLine(rdr.GetString(0));
      }
    }
  }
}

You'll then need the following dll's to be placed in the same folder as your EXE:

* oci.dll (Find 'oci.dll.dbl' and rename it to remove the '.dbl'; in ODAC1110710beta.zip \ stage \ Components \ oracle.rdbms.rsf.ic \ 11.1.0.7.0 \ 1 \ DataFiles \ filegroup2.jar)

* Oracle.DataAccess.dll (in ODAC1110710beta.zip \ stage \ Components \ oracle.ntoledb.odp_net_2 \ 11.1.0.7.10 \ 1 \ DataFiles \ filegroup4.jar)

* oraociicus11.dll (in ODAC1110710beta.zip \ stage \ Components \ oracle.rdbms.ic \ 11.1.0.7.0 \ 1 \ DataFiles \ filegroup3.jar)

* OraOps11w.dll (in ODAC1110710beta.zip \ stage \ Components \ oracle.ntoledb.odp_net_2 \ 11.1.0.7.10 \ 1 \ DataFiles \ filegroup3.jar) You may need the following dll's, but I didn't. I'd get them anyway, just to be safe, as some people say they're needed:

* orannzsbb11.dll (in ODAC1110710beta.zip \ stage \ Components \ oracle.ldap.rsf.ic \ 11.1.0.7.0 \ 1 \ DataFiles \ filegroup1.jar)

* oraocci11.dll (in ODAC1110710beta.zip \ stage \ Components \ oracle.rdbms.rsf.ic \ 11.1.0.7.0 \ 1 \ DataFiles \ filegroup3.jar)

* ociw32.dll (called 'ociw32.dll.dbl' in ODAC1110710beta.zip \ stage \ Components \ oracle.rdbms.rsf.ic \ 11.1.0.7.0 \ 1 \ DataFiles \ filegroup2.jar)

If you get the exception 'The provider is not compatible with the version of Oracle client', don't stress, simply retrace your steps and make sure you get ALL those DLL's from the same ODP.Net / ODAC distribution to avoid version number conflicts, and put them all in the same folder as your EXE (or, in the Bin folder if its an Asp.Net application, then try restarting IIS). If you download a newer version of ODP.Net, the jar files that enclose the dll's may have moved, so you'll have to manually search through them all, don't worry it won't take *too* long! Good luck!

Thanks for reading! If you found this article helpful, do me a favour and check out my upcoming web-apps: Server Scope server monitoring, and ScrumFox agile team management. And if you want to get in touch, I'd love to hear from you: chris.hulbert at gmail.