1

I'm trying to do a connection on C# with Oracle on Visual Studio 2015, and at first I had this error "could not load file or Assembly Oracle.DataAccess" then I did a lot of stuff to solve it until I found the "32-bit Oracle Data Access Components (ODAC) with Oracle Developer Tools for Visual Studio" and the problem did not appeared anymore but when I tried to Open the connection it started to appear this problem "ORA-12154 TNS: could not resolve the connect identifier specified"

I'm stuck and don't know what to do, I can connect to the database through sqldeveloper, so I think that the listener is fine.

Here the function:

 public void openDatabaseConnection()
    {

        string oradb = "Data Source=ORCL;User Id=system;Password=32310813Np;";

        OracleConnection conn = new OracleConnection(oradb);
        conn.Open();  <-- ORA-12154

        OracleCommand cmd = new OracleCommand();
        cmd.Connection = conn;
        cmd.CommandText = "select USERNAME from FDB_USER where id = 1"; 
        cmd.CommandType = CommandType.Text;

        OracleDataReader dr = cmd.ExecuteReader();
        dr.Read();

        ViewBag.QueryResult = dr.GetString(0);            

        conn.Dispose();            
    }
  • 1
    You may want to check this- http://stackoverflow.com/questions/20361325/this-is-error-ora-12154-tnscould-not-resolve-the-connect-identifier-specified and https://www.datavail.com/blog/ora-12154-tnscould-not-resolve-the-connect-identifier-specified/ – Souvik Ghosh Dec 22 '16 at 09:29
  • 1
    SQL-Developer is based on Java-JDBC which uses completely different ways to resolve and connect to Oracle database. Did you define alias `ORCL` in your `tnsnames.ora` file? – Wernfried Domscheit Dec 22 '16 at 09:55

0 Answers0