DataSource in Oracle Connectionstrings

· November 24, 2009

I had already forgot about this one… The Oracle-way of doing things is different and feels quite old to me.

Here is a short recap, it’s just for me later on – you could probably skip the next paragraph…

Normally you configure your Oracle client (ODP.NET for example) to use a datasource. This is datasource is then searched for in a file called tnsnames.ora. In tnsnames.ora you’ll find the server, port etc. that is needed to connect to the database. However – this means that you’ll need to make sure that tnsnames.ora is present and correctly configured on all the servers you plan to deploy your app on.

So – glad to be back with you – instead of this ugly tnsnames.ora thing you can put all of that information into your connectionstring:

    <add name="ConnectionName" connectionstring="Data Source=(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = = 1521))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = servicename)));User Id=[your user];Password=[your pwd];" providername="Oracle.DataAccess.Client" />

In this manner you will have “everything” you need in for the application to work in the application .config. Not spread out in different folder such as c:\app\client_1\network\admin or whatever.

I like!

Twitter, Facebook