Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to write a .Net application that works with both SqlServer and Oracle (now that System.Data.OracleClient is deprecated)

see also System.Data.OracleClient namespace discontinued?

(Firstly don’t panic yet, System.Data.OracleClient is not being removed by Microsoft yet, however it is not in the client version of .net 4)

This use to be possible by using System.Data.OracleClient, however Microsoft has decided to deprecate OracleClient. (OracleClient is the ADO.NET provider for Oracle developed by Microsoft and ships as a part of the .NET Framework.)

You could use ODP.Net, however do you wish your Sql Server customers to have to install ODP.Net? (Do you wish any of your customers to have to install Oracle software?)

DataDirect is not an option as it costs an arm and a leg; it may just about be affordable if you need to connect a single server to a mainframe. However it is not an option to expect all customers to buy it.

Moving form C# to Java is not a good option, as I am a C# programmer and wish to be able to earn a living!

Like most ISVs that have to support multiple RDBMS we only need a solution that allows us to use the small subset of Oracle that is the same as SqlServer. Therefore System.Data.OracleClient was powerful enough for us.

(Maybe we should just start storing all data in flat files, so that customer’s DBA stop trying to tell us how to write software. Oracle DBAs are the worse!)


My real question is how can I write .NET software that talks to Oracle that is us pain free to installed as .NET software that talks to SqlServer. Having to use ODP.NET just makes the oracle client install yet more painful, with yet more to go wrong.

If I was using JAVA I could just use JDBC type 4 drivers. Microsoft provides one for SqlServer and Oracle provides one for Oracle. However it seems that Oracle wishes to make .Net usage as hard as possible and Microsoft wishes to make Oracle usage as hard as possible.


So far the best option looks like devArt's dotConnect.

However I am starting to question weather .NET is a good development system for ISV, as sooner or later you always get a customer that demands oracle support. In the Java world they seem to have this problem solved.


It looks like Oracle may be about to bring out a senible Fully Managed ADO.NET provider themselfs it may even be easy to install! see here that claims Beta – 2011, Production – End of 2011.

like image 264
Ian Ringrose Avatar asked Jul 28 '09 09:07

Ian Ringrose


People also ask

What is System data OracleClient?

OracleDataAdapter Class (System.Data.OracleClient)Represents a set of data commands and a connection to a database that are used to fill the DataSet and update the database. This class cannot be inherited.

Is .NET and SQL the same?

SQL Server is one of the most powerful data platforms in the world and the . NET Framework is one of the most popular software frameworks for developing software that runs primarily on Microsoft Windows. Imagine what you can do if you combine these two technologies.

What is .NET SQL?

SQL*Net release 2.3. 3 is Oracle Corporation's latest remote data access software. It enables both client-server and server-server communications across any network. With SQL*Net, databases and their applications can reside on different computers and communicate as peer applications.


2 Answers

EDIT: The fully managed ODP.NET is now available in production. It is very small (less than 10MB) and is not dependent on other files. You can obtain it here:

http://www.oracle.com/technetwork/topics/dotnet/downloads/index.html

Original answer:

One way to easily ensure that the required Oracle client side software (including ODP.NET) is always available on the deployment machine is to embed it with your application. ODP.NET has gotten a lot easier to embed now that XCOPY ODP.NET is available. You can download it from this link:

http://www.oracle.com/technology/software/tech/windows/odpnet/index.html

With XCOPY ODP.NET, all you need to do when you deploy your application is the following:

1) Copy your application to the target machine

2) Run "install.bat" which copies a couple of Oracle DLL's to the target machine (including ODP.NET and the Oracle client side (OCI) software)

3) Run "configure.bat", which does a "gacutil" and updates the registry of the target machine

4) Provide your application with connect string information. You can use the EZCONNECT connect string ("hostname@servicename") or you (or your customer) can share preexisting sqlnet configurations by setting the TNS_ADMIN registry entry or environment variable to point to another Oracle home that has sqlnet connect aliases already configured.

That's it! It is really that simple.

I hope you will take a good look at ODP.NET XCOPY in the link above to see for yourself how easy it is these days to embed ODP.NET with your app.


Additional notes:

If you choose not to embed ODP.NET with your application, in both the case of Microsoft OracleClient and in the case of ODP.NET, there needs to be additional Oracle client side (OCI) software installed on any deployment machine. The only difference between the two cases is that when you are using ODP.NET, it also needs to exist on the deployment machine. The good news is that a typical Oracle install on your customer machine will include ODP.NET already.

Now, if your target machine already has ODP.NET installed you don't need to do anything else. You just need to distribute your application. If you do need to install ODP.NET using the standard installer, you can also download it from the link provided above. The standard ODP.NET install only takes a few minutes and configures everything for you.

And again, you can use EZConnect connect strings to make networking configuration a piece of cake, or use the TNS_ADMIN registry entry or environment variable to take advantage of pre-existing connect aliases that your customer is already used to using.

Hope this helps,

Christian Shay

Oracle

Feel free to provide your feedback on this and other future features at our feature request website: http://apex.oracle.com/pls/apex/f?p=18357:46

like image 103
Christian Shay Avatar answered Sep 19 '22 03:09

Christian Shay


Have you looked at alternate Oracle providers like devArt's dotConnect? This driver, as an example, is 100% managed code, supports many advanced Oracle features, provides Entity Framework support (that will come some day in ODP.NET, I'm sure).

There are a bunch of other features (like ASP.NET provider model support) that we didn't get until the ODP.NET 11g release. Pretty liberal licensing and reasonably priced. Also comes with it's own profiler, if I remember correctly.

In their tests, performs favorably compared to ODP.NET. I'd love to point you to something open source but, in my experience, once you've bought into Oracle as a database, you've already accepted the fact that you'll be laying down some cash for your database-related tooling.

like image 40
Thomas Beck Avatar answered Sep 19 '22 03:09

Thomas Beck