Search code examples
c#oracle-databaseoracle11godp.nettnsnames

error connecting to oracle database. ORA-12154: TNS: could not resolve the connect identifier specified


I have a SAP database deployed on a Linux server with Oracle 10g installed on it. I tried to connect to this database from Windows 8 computer using Oracle SQL Developer. Oracle 11.2.0 is installed on this Windows 8 computer. I am connecting using the following TNS entry in tnsnames.ora file

SAPTRN =
(DESCRIPTION =
   (ADDRESS_LIST =
       (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.x.xx)(PORT = 1527))
   )
   (CONNECT_DATA = (SERVICE_NAME = TRN))
)

I am able to connect successfully and can browse SAP tables as required.

Now I want to connect to the same database on the same computer using Visual studio's Add new Connection dialog. But I get below error message.

enter image description here


Solution

  • Where is your tnsnames.ora file located?

    • Create/verify Environment variable TNS_ADMIN, it must point to folder of your tnsnames.ora file.
    • Create/verify Registry key

      HKLM\SOFTWARE\ORACLE\KEY_{ORACLE_HOME_NAME}\TNS_ADMIN

      resp. HKLM\SOFTWARE\Wow6432Node\ORACLE\KEY_{ORACLE_HOME_NAME}\TNS_ADMIN

      they must point to folder of your tnsnames.ora file