Connecting C# to Oracle - c#

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.

Related

C#, Oracle 9 and entity framework development

I need to develop a local mvc web application for a company. They have an oracle 9 database but they dont want to give access for remote connections. They'll give sample tables and datas but no remote connection allowed so i have to create a development environment. My questions are
There is no oracle 9 database download link in oracle web site. Is there any link exists for download database and install on windows 10 (x64) machine for development and testing purposes.
Can i use other oracle versions for development like 10g. If sql syntax is same with 9 maybe i can get it work on the site.
Is there any chance to use entity framework with oracle 9 database?
Need help from oracle & c# gurus.
Thank you.
You should not accept such requirements for new developments.
I think Oracle 9i has been deprecated for more than 15 years. Even version 10g has been deprecated many years ago and thus not available anymore.
In general the syntax of Oracle 9i is the same as in current releases, however many function which are nowadays matter of course could be missing in Oracle 9i.
Even if you manage to get a Oracle 9i database it will be hard to connect to such DB with current Oracle client drivers.

using MySQL with C#

I want to know if it is possible to use MySQL Engine without having to install WAMP Server. I'm developing an application that will require a database, so I was thinking of using MySQL instead of MS SQL or access. So I don't want to install the WAMP package yet I want to install the MySQL Engine, so if possible, please provide me with the download link for the MySQL and how to install and use (start/stop service).
You will need the runtime and the .net connector to make this happen. You also might find the workbench (gui tools to manage the server and run queries) to be helpful.
The runtime installs a service by default, which you can control on the commandline or via the windows service management console (services.msc).
This sounds to me a lot like you're thinking 'desktop application', where the MySQL database will be a simple local data store. If that's the case, MySQL is not a good choice.
MySQL is a server-class database engine. It's designed to run full time in the background as a service. This makes it overkill for a simple desktop app, and as a user I'd be mad if your simple desktop app required me to run the MySQL service.
For the kind of app I think you're building, you really want an in-process or desktop-class database. Good examples include SQLite, SQL Server Compact Edition (not Express), or even MS Access. Any of those would be a better option here than MySQL.
On the other hand, if I'm wrong and you're building a web app or an app that will be distributed to several computers that all share the same database, then MySQL is a perfectly fine choice and you should read #Femaref's answer.
If your database isn't going to be incredibly large you could go with SQL Compact. It comes with the .NET framework, and works well for smaller databases.

DBMS for POS software

I want to develop a POS application in .NET (C#) that would be used to rent items. I have a good idea of what will be done and the famous question that I have is about the DBMS that I should use. I would like to use MySQL database.
The question is: If some places use only one computer (no network, no internet connection), can I use a MySQL database in local? Do I need to install MySQL server on all thoses computers to be able to use such a database? I know SQLite but I'm not sure if the limitations can cause problems in the future... I also looked at SQLServer Express versions.
(I must consider that other point of sales are using multiple computers and more transactions so there I can't put sqlexpress or sqlite)
So can anybody suggest me what I should do in that situation?
Thanks
You would be able to use MySQL in localhost - and it would need to be installed on each local machine.
You could use MySQL. If you are sharing a database between several computers you should just be able to install the MySQL client components.
As for which database you want to use, I would highly suggest SQL Express. The security model and tooling is much better. There is nothing stopping you from using SQL Express as a shared database server until you out grow it.
SQL Express Redistribution EULA
POS systems like Open bravo POS software where special user types and hardware devices support are required.ou can use sharing a database between several computers for using sql.

How to choose an Oracle provider for .Net application?

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.

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

Categories