Client: ORA-12154: TNS: could not resolve service name.

Pete (BSC)

Well-known member
Joined
Oct 19, 2007
Messages
89
Programming Experience
10+
I read a post regarding this same error but in the development environment; howerver, I have the same issue but when my client runs the app.

Points of interest:
  • TNSNames is valid
  • Connection string is using correct instance name, user id and password.
  • Can connect via TOAD or SQL+ (same information used as in connection string).
  • Can connection via ODBC using legacy application to same DB. (again, same information as above).
  • Only 1 Oracle Home on desktop.
  • Database is 10g, Oracle client is 9i (I'm hoping this isn't the problem).
  • Tried with and without 9i ODP.NET installed. But we are using System.Data.OracleClient, so this shouldn't matter.
  • Runs in my DEV environment (10g) against my DEV db.


Thank you in advance for any direction in solving this issue.

Pete
 
I had this again recently, after a reinstall of 10g client and my sqlnet ora went missing.

Post your sqlnet ora and tnsnames ora. If you are unhappy about posting sensitive info, put it in a passworded zip file, attach it and PM me the password

Also, your machine's DNS Client service is running, isnt it?
 
Issue Resolved

cjard: thank you for your reply. I should have posted this on Monday (11/19/07).

We were using My.Settings to store the connection string; but, the type was "User" instead of "Application" and we were not deploying the application correctly.

We put the DataSource into the exception we were throwing and low and behold it was still pointing to MY dev. Which then lead us to the setting type and at that point the exename.exe.config file was created and our connection string was pulled from that file and not from copy of app.config buried in some user's path.
 
cjard: thank you for your reply. I should have posted this on Monday (11/19/07).

We were using My.Settings to store the connection string; but, the type was "User" instead of "Application" and we were not deploying the application correctly.

My.Settings is an odd beast

Settings of type (Connection String) are application scoped which simply means that they cannot be changed at runtime (ok, they are stored elsewhere but that's an aside). THe (Connection String) type is a custom type that is TOSTRING()ed by the runtime whenever it wants to use a connection string (every time you use a tableadapter)

A hack where you change it to User Scope/String allows you to offer the user where to conenct to; you edit the conn string in My.Settings programmatically, in code at any time and every time from then on the app will connect to the new db

So dont be thinking conn strs have to be app scope///

I routinely change my conn strs to User scope AFTER i'm done changing the dataset (any attempt to edit a dataset with a user scoped conn str will break your design environment) and i offer the user a dialog on start.. do they want to conenct to test or live.. Whatever they choose, I change the conn str in My.Settings before i start accessing data. This is cool ;)

We put the DataSource into the exception we were throwing and low and behold it was still pointing to MY dev. Which then lead us to the setting type and at that point the exename.exe.config file was created and our connection string was pulled from that file and not from copy of app.config buried in some user's path.

OK, that's kinda the part that loses me a little, but yep.. whatever works.. I do occasionally hose out the user config folders and remove old app configs accumulated when things go weird, i'll watch for that one..

So, you've learned the value of putting max info into an error message eh? :)

Throw New Exception("Error connecting to db: " & ex.Message & " ConnStr in use is: " & My.Settings.COnnStr) ;)
 
Hello everybody,

I have a similar problem with Oracle (9i). I have been working with winxp sp2, VS2008, but when my company upgraded us to Vista and reinstall everything I get the same error (ORA-12154: TNS: could not resolve service name). I can successfully connect via SQL Plus, PLSQL or from cmd to the database I want to, but through VS2008 I cannot. I am not testing a new software, rather than running one that I built previously. I have used the same tnsnames.ora I have used before. Any ideas why this might happen?

Any help is highly appreciated
 
This is all gray to me now after a year; but, Vista throws a whole new set of problems in by itself. Any luck with with Googling? I do remember reading about fixes for Visual Studio and Oracle; but, I barely remember what I did yesterday let alone a year ago.

Please post back if you get anywhere, as you see old posts are still valuable.

The only thing I can suggest is to follow cjcard's suggestions and Google.

Sorry I'm not much more help.
 
Search your entire machine for all instances of tnsnames.ora. You might find that you have multiple copies, SQL plus using one (the correct one) and your VS 2008 using the/an other
 
Already done that. That's the only tnsnames.ora file instance on my pc. I am not sure if I can "tell" VS where to find the tnsnames or anything similar. Also, the vista I am using is 64bit which I am not sure if it has issues with my client. Though since plsql and sql plus works, I believe its clearly smth with .NET
 
OK here's what I have come up with after a long research. Vista 64 bit stores 64 bit programs in c:\Program Files (86x). So when trying to connect... CID=(PROGRAM=c:\Program Files (x86) etc.

What Oracle doesn't like here its the (86x), the parenthesis to be precise. The "worst" solution would be to uninstall vs2008 and reinstall it in program files instead. But I don't want to do that, as I have all previous versions of VS there, it would take ages, and it would simply by pass the problem rather than solving it, and moreover I don't know what further implications will come up. I think Oracle has a patch for this issue, for client 10.X but not for 9.0.7 on vista 64bit.

In conclusion, Vista 64bit cannot be used with Oracle 9.X.
I'll be happy to be proven wrong, but Oracle sucks in this matter as it does not provide broad support for all operating conditions.
 
but Oracle sucks in this matter as it does not provide broad support for all operating conditions

Oh come on! It was released in 2001, before XP was shipped and before vista even existed. Will you be making the same complaint in 10 years time? Are you also complaining that Windows 98 cannot run 64 bit programs?

Have you tried the 10, or 11g clients? All Oracle clients can use databases +- 2 major versions of their own version number
 
Back
Top