ORA-12162 TNS:net service name is incorrectly specified

jcoyan

Member
Joined
Jul 21, 2006
Messages
24
Programming Experience
Beginner
I've looked up information on this error, but I can't find any problems with my tnsnames.ora file. I even double checked with another machine that has the same client.

What else could be causing this error when trying to open a connection? My connection string is good.
 
post the contest of your sqlnet ora, tnsmnames, connection string and database instance inforamtion (server, port, service name etc)
 
sqlnet.ora

# C:\PROGRAM FILES\ORACLE\ORA81\NETWORK\ADMIN\SQLNET.ORA Configuration File:C:\Program Files\Oracle\Ora81\NETWORK\ADMIN\sqlnet.ora
# Generated by Oracle Net8 Assistant

NAMES.DEFAULT_DOMAIN = liebert.com

SQLNET.EXPIRE_TIME = 0

SQLNET.CRYPTO_SEED = 4fhfguweotcadsfdsafjkdsfqp5f201p45mxskdlfdasf

tnsnames.ora

# C:\PROGRAM FILES\ORACLE\ORA81\NETWORK\ADMIN\TNSNAMES.ORA Configuration File:C:\Program Files\Oracle\Ora81\NETWORK\ADMIN\tnsnames.ora
# Generated by Oracle Net8 Assistant

HUNT_ORA.LIEBERT.COM =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = huntorant.liebert.com)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = samr)
)
)

connection string

Provider=MSDAORA.1;Password=xxxx;User ID=xxxx;Data Source=samr;Persist Security Info=True
 
Also, if it's worth anything, I created a file on my desktop called "a.udl", put in the appropriate information, tested the connection, then took the connection string as it was.

That connection was fine, as well as every ODBC connection I create and test on my machine. It just won't work in my code, for whatever reason...
 
Actually, I'd have expected that connection string to look like this:

Data Source=HUNT_ORA;Password=xxxx;User ID=xxxx;Persist Security Info=True
 
The TNS name is the HUNT_ORA.LIEBERT.COM
You dont have to state liebert.com because it is the default domain in the sqlnet ora
SAMR is the name of the instance on the server; every oracle database instance has a "name" set during install. Ensure that yours is definitely called SAMR

Also, I find this in my SQLNet ora:

SQLNET.AUTHENTICATION_SERVICES= (NONE)
NAMES.DIRECTORY_PATH= (TNSNAMES)

It might not matter, or you can try adding them
 
Every file having to do with Oracle should be correct as is. They are installed as part of a package that is pushed out by our admins via Zenworks.

Do you know why every ODBC connection I create on my machine would work, but this code would not? I kept thinking it was a connection string issue...

For example: Creating a System DSN with "hunt_ora" as the service name, then using that DSN to link tables in Access, works perfectly fine.

Changing the Data Source in my connection string to HUNT_ORA instead of samr gives me the same error message.

Also tried adding both lines to sqlnet.ora, with no luck.
 
I am on .NET 2.0, using VS 2005.

You must specify a provider in your connection string, or you get an error telling you to do so.

I just forgot to update my profile....sorry.
 
Interestingly, none of my connection strings have the provider specified!?

If youre on .net 2, take a look at the following video I did for you.. As you will see, the provider is not specified.

Note that I use
".NET FW Data Provider for Oracle" rather than
".NET FW Data Provider for OLE DB"

Double check what youre using.. When I use the OLE one, understandably I'd expect the provider needs nominating
 

Attachments

  • screencap.zip
    127.3 KB · Views: 24
My tnsnames.ora here looks like:

db1 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS =
(COMMUNITY = tcp.world)
(PROTOCOL = TCP)
(Host = server1)
(Port = 1521)
)
(ADDRESS =
(COMMUNITY = tcp.world)
(PROTOCOL = TCP)
(Host = server1)
(Port = 1526)
)
)
(CONNECT_DATA = (SID = db1)
)
)
 
Back
Top