I was researching today how one connect to an Oracle database from .Net using Visual Studio 2008 and ODP.Net (Oracle Data Provider for .Net). What I initially tried and what I will talk about is to add a new datasource to a project. I will not go into specific programatic access but into configuration.

First thing you have to do is download ODP.Net from the link above and install it. In the installer two things have to be done. Select the type of install and pass the prerequisites. On the type of install I could not understand the choices mainly because the texts for the two available was 90% identical, but the ideea is that the first one is for instalation on a machine that does not have the oracle installed on it, while the second was for the machines with it.

The second part of the install is also nasty from a usability point of view. I am running Windows 7 RC1 and at this time the installer does not recognize it as a supported OS. Fair enough, but you have to guess that you need to tick the checkboxes of the failed prerequisites in order to be able to continue. Afterwards it was click and continue until, again you are dumbfounded at the end screen. It says everything is done and you have a close button and that asks if if you are sure you want to exit. Are you crazy ?! What else can be done on that screen!

So we now have ODP on our machine. Fire up Visual Studio and open your project and the “Add new data source” wizard. Select New connection and ODP and that should do it. NOPE! This is not an MS driver, you have to work to get things done. You have to go now to the directory where ODP was installed, in the Network\Admin subdirectory and copy from the sample subdirectory into its root the two files “tnsnames.ora” and “sqlnet.ora”. Then modify them according to your oracle configuration (you can find examples on the web).

After modifying the configuration files go to Visual Studio again but make sure (if you’re on Vista or Win7) to run it as administrator. In the add new connection when selecting the ODP.Net driver you are now presented also with an option for your particular connection specified in the tnsnames.ora. Another trick needed here is that when filling in the user name this is automatically transformed to uppercase. If you have a username in lowercase you need to go to advanced and change it to lowercase from there.

Done. Really … done. You have now a data source connection and can create your datasource from an Oracle database. What it’s left is to get your hands on a linq connector for Oracle … but you have to go to other parties like DevArt because Oracle can’t be bothered.

Cheers

Leave a Reply