Tim Tim - 21 days ago 7
ASP.NET (C#) Question

ASP.NET / Oracle issue: TNS Could not resolve the connect identifier specified

I've got a local copy of an ASP.NET web application running in Visual Studio 2010. The code is an exact duplicate of the code running on my dev environment.

When I try to connect to my Oracle database through ASP.NET, it throws a "TNS could not resolve the connect identifier specified." The weird thing is this database is in my TNSNAMES.ORA file, and when I use TNSPING or Microsoft Data Link to connect, it works fine.

I tried tinkering with the permissions on my Oracle directory, but that didn't seem to help.

Answer

Make sure you have installed the Oracle Database client (x86 or x64).

Make sure you have the PATH configured to use the Oracle bin folder:

PATH=C:\Oracle\product\11.2.0\client_1\bin

Make sure your tnsnames.ora file is in the directory:

C:\Oracle\product\11.2.0\client_1\network\admin

You can try and use the following connection string:

Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.1)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=MYDATABASE)));User ID=myusername;Password=mypassword;

UPDATE:

I don't have this environment variable (cause I use the extended connection string) but someone here and here suggest to add TNS_ADMIN.

Comments