Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connecting C# app with Oracle 10g: ORA-12154: TNS:could not resolve the connect identifier specified

I am a beginner in working with databases. I am trying to access Oracle10g database from a c# application. But when I do so i get this error:

ORA-12154: TNS:could not resolve the connect identifier specified"

I'm using the following code:

string oradb = "Data Source=ORCL;User Id=system;Password=goodbye;";
OracleConnection conn = new OracleConnection(oradb);  // C#
conn.Open();

Is there an error in the connection string oradb?

like image 975
amulous Avatar asked Sep 16 '12 07:09

amulous


1 Answers

Start the Visual Studio, open View menu + Server Explorer.

  1. Right mouse click on Data Connection + Add Connection + Select Oracle Database
  2. server Name : localhost or name of your machine, set username & password and click on Test Connection to verify the above parameters. Press OK if test is succeeds.

From properties windows you can obtain connection String and it should be look a like:

Data Source=localhost;Persist Security Info=True;User ID=scott;Password=***********;Unicode=True
like image 84
KV Prajapati Avatar answered Sep 30 '22 09:09

KV Prajapati