JG Vimalan's Blog

It is all about coding!

ORA-12154: TNS:could not resolve the connect identifier specified

I got this error in my development system when I am trying to connect a oracle 10g database via my WCF serivce developed in .NET 4.0 framework.

The wcf service was running in IIS 7.5 and using the DefautAppPool. My suspect was the oracle client installed in my system. I could see that, I had different instances of Oracle 11g client in my system. So, I thaught of identifying the active one.

Inorder to find that, I opened the command prompt and typed tnsping <oracle database name>. Now, I was able to see the active oracle instance in my system as shown below,

In my case, it is client_2. Apart from this, I had client_1 and client_4 installed in my system.

As a next step, I verified the registry and found that, different instances of oracle exists as shown below,

Now, I modified the ‘Oracle Home’ for all instances to point to the correct location (in my case, it is client_2). See below,

I then recycled the application pool.

Tried to connect the oracle database via code and it worked!

April 26, 2012 Posted by | C#.NET, Oracle | 5 Comments

{System.InvalidOperationException: No data exists for the row or column.

I got this error when I was trying to read values from an OracleDataReader in my C# application.

Here is the code snippet which caused the issue,

OracleDataReader orReader = command.ExecuteReader();
if (orReader.HasRows)
string email = orReader.GetValue(0).ToString();

The cause of the error is simple, I have not used orReader.Read() method.

All I have done is, just verified whether reader has rows. The correct code is as follows,

OracleDataReader orReader = command.ExecuteReader();
while (orReader.Read())
string email = orReader.GetValue(0).ToString();

June 25, 2011 Posted by | C#.NET, Oracle | Leave a comment

Configuring Oracle SQL Developer in Windows 64 bit OS

Oracle Sql Developer is a powerful tool for accessing Oracle databases.

The developers who are familiar with Sql Server Management Studio will certaily like this tool.

The steps given below is for developers having difficulty in using SQL Developer on Windows 64 bit OS.


Ensure that, you have latest version of JDK installed in your system.

You can get the JDK from the location given below,


While downloading JDK, select the operating system as Windows 64 bit


Download SQL Developer (for Windows 64 bit) from the following location,



Extract the zip file. Locate the sqldeveloper.exe and double click it.

It will ask you to locate the java.exe file.

Now, browse to the location where the JDK is installed and locate the java.exe file.

Usually, it will be like,

C:\Program Files\Java\jdk1.6.0_21\bin\java.exe


Set the TNS names correctly in the tnsnames.ora file. The file is usually located in a location as shown below,

C:\app\<User name>\product\11.2.0\client_1\network\admin


Now, launch the SQL Developer.exe.


Provide the database details you wish to connect to.

May 31, 2011 Posted by | Oracle | 1 Comment

Re-distribute Oracle dll’s to Production/Client system via .NET setup application

I got a client requirement where a .NET setup has to be installed in several users system. This .NET setup installs a console application which connects to Oracle database and performs some action. In development environment, we have installed Oracle 11g client and it is must for connecting to Oracle database. But, it is not possible to request users, who are going to use the application to install Oracle client software in their system. So, I decided to re-distribute necessary Oracle dll’s to every user’s systems via the .NET setup project. By this way, user’s are no longer required to install Oracle client in their system to connect to Oracle database. Inorder to achieve that,

Add the following Oracle dll’s in the .NET setup project’s ‘Application Folder’.


I got the above dll’s from my development system where I have installed Oracle 11g client. The dll’s will be available under the “product\11.2.0\client_1” location in Oracle installation directory. After adding the dll’s, your setup project will look as shown below,

Thats all. Now, install the .NET setup in any user’s system and you will find that, the necessary oracle dll’s are copied to the installation directory and your application is able to connect to target Oracle database, even without the Oracle client installed.

April 1, 2011 Posted by | .NET Installer, Oracle | 6 Comments