How to choose an Oracle provider for .Net application? - c#

I am trying to figure out what is the best way to connect an (existing) ASP.Net application to an Oracle database to read its dictionary information.
There are simply too many possibilities:
MS Data Provider for Oracle (requires 8.1.7, namespace System.Data.OracleClient)
Oracle Data Provider for .NET (requires 9.2, namespace Oracle.DataAccess)
Oracle Provider for OLE DB
MSDASQL and ODBC
As my current app uses MSSQL server, further options would be:
Linked Server, access via server..user.object
Linked Server via OPENROWSET
There are a couple of questions on similar topics on SO, but only some have accepted answers.
What's your experience with each of the drivers? What are their pros and cons?
Of course Oracle is recommending ODP.Net. Is the requirement of version 9.2 (or higher) a problem today?

I too recommend ODP.NET. Choose the latest provider (http://www.oracle.com/technology/tech/windows/odpnet/index.html). It can connect with an Oracle 9.2 database or a newer release of the database.
The MS Data Provider for Oracle is very limited. You can't work with arrays for example and user defined types. And why would Microsoft provide good support for connecting to Oracle?
You can also check out the provider of devart: http://www.devart.com/dotconnect/oracle/ . It supports the entity framework.

Dump OLE DB and ODBC options, if you have direct data access provider there is no need in using OLE DB or ODBC.
I recommend Oracle Data Provider for .NET.

Microsoft just announced it is deprecating System.Data.OracleClient.
I think that leaves you with a few choices (at least):
ODP.NET (free, from Oracle)
DevArt
DataDirect
DevArt also has a LINQ to Oracle implementation which could be interesting to you.

Related

.NET report getting data from both MSSQL and Oracle

We are using SQL Server 2016 and Oracle 11g (in the process of upgrading to Oracle 12c) .
I'm not a .NET developer; therefore, examples will be very helpful.
Our developers are trying to combine data from both MSSSQL (in-house applications) and Oracle (ERP systems) to create a report in .NET (so just reading from both databases).
The developers are adamant they need to install Oracle client on the server hosting MSSQL.
From the security perspective (surface area exposure), we are encouraged to minimize surface area exposure as much as possible. And I found a possible way on this blog. And this blog that seems to suggest creating a function as connection string.
Questions:
Is there not an option in .NET (array, etc) to hold data from either MSSQL and / or Oracle in memory for comparison (using employee id) with another database?
Since it's only a read, is it an overkill to have full Oracle client installed on the server?
How are the experts here if you need to pull data from both DBs?
Thank you.
At some point a machine will have to have the Oracle client. I don't know of a way to connect to Oracle without it.
I can think of two ways to do this. You can link Oracle tables directly in SQLServer. I presume you can then use the SQLServer dialect to query the Oracle table. I'm sure there is a performance penalty for this, especially if joining across RDBMSes.
A second option is to have some sort of table on your SQLServer that has a copy of the Oracle data. Depending on how much data there is or whether or not you retain it, it could be faster than querying the linked table with a join. It could be a permanent table or a temp table. You'll still need to query the Oracle machine and this done as needed or on a schedule.
If you have very little data, you may not even need a table.
You could also have another machine that performs the query of the Oracle DB and moves the data to SQLServer. You wouldn't need the Oracle client on your SQLServer, but on that machine.
I'd look into building a windows service running on a different server from MSSQL server that would utilize the managed Oracle client to ETL data from Oracle to MSSQL server on a schedule which would allow your .NET report to access the report data from one location, your MSSQL server.

Is Nhibernate using ADO.NET for connecting to database?

What is the data provider for nhibernate? Is it ADO.NET?
Yes it uses ADO.NET internally.
Take a look at http://community.jboss.org/wiki/DatabasesSupportedByNHibernate.
It shows what tools/drivers are used to connect to different databases. for example:
Oracle 9i and 10g are supported, both using Microsoft driver (System.Data.OracleClient) and using Oracle driver (Oracle.Data.OracleClient).
Or:
To work with Firebird, install the latest Firebird .NET Data Provider.
I'm not sure whether it uses ADO.Net for SQL Server connections under the hood, But it seems that it doesn't use ADO.Net for other database systems.

Connecting C# to Oracle

What is the best library/driver to connect C# (.NET) application to Oracle 10g and 11g.
Current options that I found are:
Oracle client that comes with database installation
Oracle Instant Client (which is a bit confusing since it has 6-8 versions for number of operating systems)
Microsoft ODBC ? (Can this be used?)
ODP.Net - is this separate product or is it included in 1. and 2. ?
Can somebody explain differences?
I am planning C# application that will do basic CRUD operations on Oracle database. Which library/driver is smallest and easiest to install?
Edit:
General recommendation is to use ODP.Net. Now, can somebody please explain or point to answer about differences between client install packages. I found 3 different clients for Oracle 11g:
Oracle client - client drivers package that ships as part of database installation
ODAC - Oracle data access components, contains lots of things, among them are ODP.Net and Oracle Instant Client
Oracle Instant Client which also contains many things, including ODP.Net
So, which of those is enough for development? Oracle documentation is painfully detailed, but says nothing about differences between those client packages. I would go with smallest (Instant Client). Is it best choice?
Edit 2:
I am using .Net 3.5
Microsoft will deprecate the System.Client.OracleClient namespace so I think it will be best to use ODP.NET. Make sure you download the latest one (ODP.NET 11g) as previous versions had some issues.
To connect C# to oracle you need a data provider for .net. This can be one of the following:
ODP.Net (Oracle)
System.Data.OracleClient (Microsoft)
ODBC (Oracle)
OLEDB (Oracle)
DataDirect ADO.NET Data Provider for Oracle (DataDirect)
may be some other provider
All of this data provider need an oracle client installed. There is no standalone library as jdbc14.jar as in java. You have 2 choices deploying an oracle client:
full client (may be from database installation)
instant client
ODP.Net, ODBC, OLEDB are part of full client. This is the "hard" way because an installation process must be run on every client runing your software. This is where the most megabytes are put on the client.
The instant client is provided in different packages. This is the smallest way for deployment of an oracle client.
I would suggest using ODP.Net with Oracle Instant Client, because this easy to deploy and very very light weight.
Which instant client packages do you need:
Pick version 11.1.0.6.0 (or newer where ODAC is provided)
Instant Client Package - Basic (if you need full language support)
Instant Client Package - ODAC
There are a lot of articles on stackoverflow about deployment of oracle instant client with c# applications.
EDIT: updated links and versions
ODP.NET is the best provider for accessing Oracle db, mostly - because it's the most native one, which differentiates it from ODBC by the following:
better performance
ODP.NET provides access to advanced Oracle functionality, not available via ODBC .NET
ODP.NET does not use an extra data access bridge.
ODBC can also be used but as mentioned above it's going to be slower and have limited functionality.
For making ODP.NET work you need the software listed here (and including oracle client):
http://www.oracle.com/technology/tech/windows/odpnet/faq.html#install
Hope this helps!
Maybe I'm wrong but ADO.NET have integrated support for Oracle. maybe for earlier versions...
I think odbc is too slow. System.Data.OracleClient is a bit slow too and it will be deprecated by Microsoft.
You could use devart's provider, there is a free version. It is easy to deploy. See here http://www.devart.com/dotconnect/oracle/ It does support the entity framework.
Odp.net is fast but it doesn't support the entity framework and it isn't very easy to deploy.
I really cannot say the differences between the solutions you provided but I always used the Oracle Data Access Components from Oracle and it always worked flawlessly. It could be found here : ODAC for Visual Studio
What is sure is that a library developped by Oracle on the .NET Framework will be much more accurate than a library developped by an company external to Oracle. For example, concerning exceptions thrown when accessing an Oracle database, they will be much more helpful if the library have been developped by the Oracle developping team as they have additional knowledges on Oracle DBs.
The bad thing is that you will have a dependency, problem that you will not have to overcome if you chose to use the .NET System.Data.OracleClient.
Hope this helps. Regards.
EDIT : The ODAC package contains ODP and Oracle Developer Tools
ODP.NET is a native provider fo accessing oracle db. And hence it should be better optimized for oracle db. Moreover, there are oracle feature, such as REF CURSOR type, which are not supported by MS ODBC, but supported by ODP.NET. You can download ODAC, which include ODP.NET as well, on the www.aracle.com website.

Connectiong from C# to MySQL without any third party components?

I was always connecting to SQL which was simple, but now I would need to connect to a MySQL server. I thought System.data.odbc connection will work, but it doesnt connect. I do not udnerstand whather I really need to download and install any third party stuff like Connector or even MyODBC, I thought ODBC in .NET is enough. Could you please advice?
So far I am using:
string ConString = #"driver={MySQL ODBC 3.51 Driver};server=localhost;database=db;uid=band;pwd=letmein;";
dbconn.ConnectionString = ConString;
dbcon.Open();
Thank you in advance.
There are various possibilities to connect to a MySQL database. A list of them (and the necessary connection strings) can be found on this excellent site: http://www.connectionstrings.com/mysql
Edit: Since you're trying to avoid third-party connectors (even though I recommend them, because they were written specifically for the target db), you should look out for ".NET Framework Data Provider for OLE DB" or ".NET Framework Data Provider for ODBC" in the list
You need either a odbc driver for MySQL or a .Net Framework Class to use (ie MySql.Data.MySqlClient.MySqlConnection)
.Net and Windows doesn't include native support for MySQL

asp.net dynamic data with access

can you use ms access as the backend of a asp.net dynamic data project website. Any links or examples?
At first I thought that this should be possible, because .NET generally supports ODBC and thus connecting to a MS Access database. Linq to SQL and the ADO.NET Entity Framework seem to be the most popular data providers for ASP.NET Dynamic Data. However, there seem to be some issues which require modifications to the data providers in order to make them compatible to EF, and Linq 2 Sql supports MS SQL Server only. Because of that, just MS SQL Server and MS SQL Server Compact seem to support EF at this moment. There is one last hope, though. According to this post on the Microsoft forums, you could implement your own Entity Framework Provider to support Access or ODBC in general.

Categories