Link to home
Start Free TrialLog in
Avatar of vamshiav1
vamshiav1

asked on

ORA 12154 : TNS : could not resolve the connect identifier specified( error in C# code)

Hi, I am trying to connect to oracle database 10 g using visual C# 2005. I am using ODP.Net for connecting to the database. I have configured .Net Configuration Assistant in the Programs->Oracle-OraDb10g_home1->Configuration and Migration Tools ->.Net Configuration Assistant.  I have installed ODP.Net on my machine.  I have referenced Oracle.DataAccess.dll (under dir client1) in the program ( in solution explorer ->add reference).Below is my code:
using System;
using System.Collections.Generic;
using System.Text;
using Oracle.DataAccess.Client;
namespace VamConnect
{
    class Program
    {
        static void Main(string[] args)
        {
            string constr = "User Id=SYSTEM;Password=mskiranavk;Data Source=orcl";
            OracleConnection con = new OracleConnection(constr);
            con.Open();
            Console.WriteLine("Connected to Oracle" + con.ServerVersion);
            con.Close();
            con.Dispose();
         
        }
    }
}
When I try to run these code I am getting an unhandled exception :ORA 12154 : TNS : could not resolve the connect identifier specified. I have tried to change the tnsnames.ora and listener.ora , however could not connect. Anyone please help me with this code. Its urgent...
thanks in advance
vamshi
SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of vamshiav1
vamshiav1

ASKER

hi angel thanks for the response:
The contents of TNSNAMES.ORA:

# tnsnames.ora Network Configuration File: C:\oracle\product\10.2.0\db_1\network\admin\tnsnames.ora
# Generated by Oracle configuration tools.

ORCL =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.0.26.99)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = orcl)
    )
  )

EXTPROC_CONNECTION_DATA =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
    )
    (CONNECT_DATA =
      (SID = PLSExtProc)
      (PRESENTATION = RO)
    )
  )

LISTENER.ORA :
# listener.ora Network Configuration File: C:\oracle\product\10.2.0\db_1\network\admin\listener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = C:\oracle\product\10.2.0\db_1)
      (PROGRAM = extproc)
    )

   )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
      (ADDRESS = (PROTOCOL = TCP)(HOST = ITSPH316_5.aamu.edu)(PORT = 1521))
    )
  )
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Here are the contents of sqlnet.ora:
# sqlnet.ora Network Configuration File: C:\oracle\product\10.2.0\db_1\network\admin\sqlnet.ora
# Generated by Oracle configuration tools.

# This file is actually generated by netca. But if customers choose to
# install "Software Only", this file wont exist and without the native
# authentication, they will not be able to connect to the database on NT.

SQLNET.AUTHENTICATION_SERVICES= (NTS)

NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)
Check oracle homes as I said. Your tnsnames/sqlnet seems ok.

I think you've installed oracle in your machine, isnt it? Did you try connecting it from sqlplus, whats the response?
I have installed oracle 10 g on my system. I have only one instance "orcl" installed on the machine. and from
SQL , I could connect using the below code.
SQL> connect SYSTEM/mskiranavk@orcl
connected...
let me try your solution and I will let you know.. thank you for replies ram...
did u try tnsping from ur dos prompt

check this, it might be possible that ur path for Oracle & Windows having issues

and if still doesnt work then try this

start > programs > ... > Net Configuration Assistant

here u should able to add & test your listeners

hope this assists!
I have created another SID orclvam on my system.ram I have checked all these steps . Program is not working...
thank you..
vamshi
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
hi folks I got my program working... this was my problem:

In Visual C# 2005, when you try to connect to the oracle database10 g using ODP.Net, if you get
the following error(after installing ODP.Net and configuring Net Configuration assistant)...

Error ORA 12154 TNS: could not resolve the identifier name specified:

Try the below solution:

The three files in the SQLNET.ORA , LISTENER.ORA, TNSNAMES.ORA in the
oracle database side should also be present in the client side after
installating it.

To say in exact terms:
The three files(same files) in
dir(C:\oracle\product\10.2.0\db_1\NETWORK\ADMIN) should also be present in the
dir(C:\oracle\product\10.2.0\client_3\network\ADMIN).

If not present just copy and past the three files in client side and try to run the c# code.
That shuuld solve the problem.

C:\oracle\product\10.2.0\client_3\network\ADMIN

Thank you for responses.. my program is working