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: \ stage \ Components \ oracle.ntoledb.odp_net_2 \ \ 1 \ DataFiles \ filegroup4.jar

Copy it into your project (For winforms: the same folder as your project's Program.cs; For 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))
  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())

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 \ stage \ Components \ oracle.rdbms.rsf.ic \ \ 1 \ DataFiles \ filegroup2.jar)

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

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

* OraOps11w.dll (in \ stage \ Components \ oracle.ntoledb.odp_net_2 \ \ 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 \ stage \ Components \ oracle.ldap.rsf.ic \ \ 1 \ DataFiles \ filegroup1.jar)

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

* ociw32.dll (called 'ociw32.dll.dbl' in \ stage \ Components \ oracle.rdbms.rsf.ic \ \ 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! And if you want to get in touch, I'd love to hear from you: chris.hulbert at gmail.

Chris Hulbert

(Comp Sci, Hons - UTS)

iOS Developer in Sydney.

I have worked at places such as Google, Cochlear, News Corp, Fox Sports, NineMSN, FetchTV, Woolworths, and Westpac, among others. If you're looking for a good iOS developer, drop me a line!

Get in touch:
[email protected]
my resume

 Subscribe via RSS