Search code examples
asp.netoracleclienttns

TNS:could not resolve the connect identifier specified in .NET OracleClient


Im using a .net OracleClient in my machine for connecting to a Database in Oracle. When im trying to connect its showing this TNS Error.

Now, I have edited the tnsnames.ora file and sqlnet.ora file. When I access the Oracle using a ServerExplorer. It gets connected to the Oracle Database and its fetching everything.

I do have a ODAC component from oracle website itself which also, i tried but dint worked.

My connection string is<add name="netOracleClient" connectionString="Data Source=ff.WORLD;Persist Security Info=True;User ID=vlc;Password=vlc;Unicode=True" providerName="System.Data.OracleClient" /> <add name="ConnectionString" connectionString="DATA SOURCE=ff.WORLD;PASSWORD=vlc;USER ID=vlc" providerName="Oracle.DataAccess.Client" />

I tried with ServerExplorer in both the components. Its working FINE with Server explorer and im getting the datas too. But when i write the code its throwing me this error ORA-12154: TNS:could not resolve the connect identifier specified

This is the code from which Im trying to connect.

 OracleConnection con = new OracleConnection(WebConfigurationManager.ConnectionStrings["netOracleClient"].ConnectionString);

Tell me a way to resolve this???

NOTE: We have machines here itself from which we are accesing the same database with the same TNS using OracleClient for .net. I also wants to use the same..

Please Help me in this.


Solution

  • Now Its working for me. The steps we followed for doing this.

    • We noticed we were having more than One TNSNames.ORA file.
    • Then we could find it was pointing to Oracle Client version 8.x.So it was not working properly. So for working with it...
    • We removed all the ORacle Client Versions(since we were not able to point VisualStudio Oracle Client to a newer version)

    • Re-Installed it again. After a Restart it started Working.