Click here to Skip to main content
15,891,633 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
C#
using System.Data.OracleClient;
	
string strDSNcon = "Data Source=myOracleDB;uid=uid;pwd=myPass;";
OracleConnection oraConn = new OracleConnection(strDSNcon);
oraConn.Open();


myOracleDB version is 11.2.0 - 64bit

when I try to execute this code, it throws an error-

ORA-12154: TNS:could not resolve the connect identifier specified
at System.Data.OracleClient.OracleException.Check(OciErrorHandle errorHandle, Int32 rc)

I googled this error and there are a lot of possible cause. but nothing is applied in this scenario.

Is this problem of Oracle 64bit?
Posted

1 solution

Hi ,

Make sure you add reference Oracle.DataAccess
C#
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;


                string oradb = "Data Source=(DESCRIPTION="
                + "(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.1)(PORT=1521)))"
                + "(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=test.eg.com)));"
                + "User Id=scott;Password=123;";


                OracleConnection con = new OracleConnection(oradb);
                con.Open();

http://www.connectionstrings.com/oracle[^]
Best Regards
M.Mitwalli
 
Share this answer
 
v2
Comments
Manas Bhardwaj 3-Sep-12 6:23am    
Yes 5!
Mohamed Mitwalli 3-Sep-12 6:27am    
Thanks Manas

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900