6

Is there any way to connect to Oracle DB without installing oracle client or using tnsname ? The application needs to be deployed on client machine ,hence want it to be INDEPENDENT.

jen123
  • 61
  • 1
  • 1
  • 4
  • I won't go as far as saying it's not possible but everyone makes installers to do this type of deployment, any particular reason why you don't want to install the dependency? – Jeremy Thompson Nov 04 '15 at 10:48
  • Use Oracle's *Managed* ODP.net. It removes the dependency for a local client, but on the downside you lose access to many of the advanced features of OCI like bulk inserts and updates – Hambone Nov 04 '15 at 14:55

1 Answers1

3

To clarify on my comment, this is possible with the Managed ODP.net from Oracle, which does not require the client machine to have any Oracle clients/drivers installed. It's perfect for Windows or console applications where you can't control the software that's installed on the target machines.

To download the managed client, you can get it from nuget using the Library Package Manager (https://www.nuget.org/packages/odp.net.managed/):

PM> Install-Package odp.net.managed

With regards to TNSnames (since that is also a client dependency), if you use Oracle's EZ Connect, you can bypass TNSnames completely. To do this, you simply format your data source as server-name:port/sid. I actually stopped using TNSnames completely ever since this became available.

Here is an example of how you can do this with Managed ODP.net:

OracleConnectionStringBuilder sb = new OracleConnectionStringBuilder();
sb.DataSource = "MyOracle.MyCompany.com:1521/MySid"; // EZ Connect -- no TNS Names!
sb.UserID = "luke";
sb.Password = "Jedi4Eva";

OracleConnection conn = new OracleConnection(sb.ToString());
conn.Open();

OracleCommand cmd = new OracleCommand("select * from dual", conn);
object o = cmd.ExecuteScalar();

conn.Close();
Hambone
  • 15,600
  • 8
  • 46
  • 69