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->Con figuration 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=mskiran avk;Data Source=orcl";
OracleConnection con = new OracleConnection(constr);
con.Open();
Console.WriteLine("Connect ed 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
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=mskiran
OracleConnection con = new OracleConnection(constr);
con.Open();
Console.WriteLine("Connect
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Here are the contents of sqlnet.ora:
# sqlnet.ora Network Configuration File: C:\oracle\product\10.2.0\d b_1\networ k\admin\sq lnet.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_SERV ICES= (NTS)
NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)
# sqlnet.ora Network Configuration File: C:\oracle\product\10.2.0\d
# 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_SERV
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 think you've installed oracle in your machine, isnt it? Did you try connecting it from sqlplus, whats the response?
ASKER
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...
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!
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!
ASKER
I have created another SID orclvam on my system.ram I have checked all these steps . Program is not working...
thank you..
vamshi
thank you..
vamshi
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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\NE TWORK\ADMI N) 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\c lient_3\ne twork\ADMI N
Thank you for responses.. my program is working
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
dir(C:\oracle\product\10.2
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\c
Thank you for responses.. my program is working
ASKER
The contents of TNSNAMES.ORA:
# tnsnames.ora Network Configuration File: C:\oracle\product\10.2.0\d
# 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\d
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = C:\oracle\product\10.2.0\d
(PROGRAM = extproc)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = ITSPH316_5.aamu.edu)(PORT = 1521))
)
)