Oracle and C# Tutorial
21/4/07: Please note before continuing to read: I have decided that this document and tutorial will need to be re-worked to allow for an easier transition to later tutorials. It does work as it stands, but the approach might be changed in future.
I experienced some issues getting started with C# / Visual Studio 2005 and connection to an Oracle Database. Working with the Oracle Data Provider and Developer Tools for .Net is not quite the same as working with the equivalent tools for MS databases.
This page presents a tutorial that I wrote to document the processes necessary to get up and running with the two systems. It’s in a format that I felt would represent, after tweaking, a reasonable real-world example of how .Net v2 applications could be coded. Hopefully, if time permits, I will extend the tutorial to make it more real-world.
The tutorial is presented as a 14-page pdf (with lots of screen shots) and a zipped VS2005 C# Project file. The following text is an extract of the introduction to the tutorial, so you can check if it will be useful to you prior to downloading.
Visual Studio 2005 provides tight integration through ADO.Net, to SQL Server databases. Facilities such as drag-and-drop creation of forms with connections to the database are possible, as is the creation of strongly-typed DataSets through drag-and-drop.
Those who wish to connect to Oracle, however, have slightly less convenience (though hopefully some of the current short-comings will be ironed out in an upcoming beta release of their Oracle Data Provider.
What You Will Achieve
We will, however, have created a means of getting data from the Oracle DB that allows us to use the latest data-bound components on top of them, with strong typing.
Technologies and Prerequisites
This document concentrates on the following technologies:
- Visual Studio 2005 SP1 (.Net framework v2) using C#;
- Oracle 10g2R2 Database server (running on Windows);
- Oracle Data Access Components 10.2.0.2.20, including Oracle Data Provider and Oracle Developer Tools for .Net;
- If you want to use .Net Stored Procedures (outside the scope of this document) you will have had to do a manual install of the database, being careful to include the Oracle Database Extensions for .Net (ODE). Then you need to install ODAC and the included ODE update over that. Oh… and don’t forget needing the .Net Framework on the server too.
You will need to have all of the software mentioned previously installed to work through this tutorial. In addition you will need to have access to the human resources demo database; typically accessed through user hr.
You will also need to be able to access the database from your development machine; you may need to set up a service name through Oracle Net Manager or Net Configuration Assistant software that was installed with ODAC.
This work is licenced under the Creative Commons Attribution-Non-Commercial-Share Alike 2.0 UK: England & Wales License. To view a copy of this licence, visit creativecommons.org/licenses/by-nc-sa/2.0/uk/
Download the Rest of the Tutorial
If you wish to read the full tutorial, you will need to download the following pdf file. If you want to view the code, or see the finished result in your Visual Studio environment, download the project Zip file too.