Friday, October 7, 2011

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

Hi guys,

If you are trying to connect to an Oracle Database, through Server Explorer in Visual Studio, you have to ensure that:

1. You have installed the Oracle Data Provider (downloadable from the Oracle Website)
2. Have created the tnsnames.ora file, holding information about the databases (http://www.orafaq.com/wiki/Tnsnames.ora). This file should be created most often in the Network\Admin folder under the Oracle Provider. In my case: C:\app\user\product\11.2.0\client_1\Network\Admin

After having these prerequisites, I still couldn't connect to the Oracle Database. The Visual Studio wizard told me: "ORA-12154: TNS:could not resolve the connect identifier specified". What resolved this issue for me was to add the Environment Variable with name "TNS_ADMIN" and value the Path to the directory containing the "tnsnames.ora" file.
Something like:
TNS_NAMES="C:\app\user\product\11.2.0\client_1\Network\Admin"
Then just restart Visual Studio and you're free to go.

Hope this helps someone out there :)

24 comments:

Anonymous said...

Has the same issue as you and this blog post helped me resolve my issue.
Thanks .........

Anonymous said...

this helped me a lot. i love you man.

Kannan said...

will u please explain me further clear.. am using oracle 10g express edition.. i am facing this problem for a week.. pls help me..

abdul sharique said...

Hi kannan
Can u plz share oracle database 10g . bcoz we r unable to find it on Oracle site.

Anonymous said...

You are the man! It worked pretty easy.

Anonymous said...

how can i add enviorment variable ??

kindly tell me please

cypressx said...
This comment has been removed by the author.
cypressx said...

Hi, please take a look here:
http://www.windows7hacker.com/index.php/2010/05/how-to-addedit-environment-variables-in-windows-7/

There is a step-by-step guide with screenshots.

Best,
Yosif

Kishore Peddada said...

Yosif...YO man .THANK YOU

You same hell of time, I was breaking my dead, I did added environment variables, but not restarted VS2010

After reading your blog, I restarted VS, it started working..thanks

alain said...

I spent hours Binging/Googling on this topic. Yosif, You're the man!

kutu kupret said...

ya da man yosif, btw do you know how to add TNS_NAMES variable in visual studio installer?

Anonymous said...

Thank you!

Anonymous said...

Thank you!

Anonymous said...

Yosif - BIG THANK YOU!!! I spent literally days trying to figure this out - I pulled my hair so much that I lost half of my hair :) Damn oracle, add this in your manual.

Adrian Soto said...

MAAAANN !!!! you totally save my life !!!!
thank you so much :D

Anonymous said...

many blessings upon you good sir

Anonymous said...

Thanks!!!

Anonymous said...

This fixed my connect error!
Thanks

Const said...

Man, thank you very much.

Anonymous said...

Thank you very much! After 10 hours, I solved the problem thanks to you! Super! :-)

Amir said...

Thanks alot. This helped me a great deal

Anonymous said...

Thanks For Your Post :) Its Great

Anonymous said...

WOW it worked!.
After reading alot of posts finally work. thank you.

Tasnim Musharrat said...

system.data.oracleclient requires oracle client software version 8.1.7 or greater........still showing this after doing properly every steps.. :(