Reputation: 7605
VB.Net app is getting this error. However when i open SQL Plus from command prompt, I can connect with no problem
ORA-12154: TNS:could not resolve the connect identifier specified
I am not sure what to do here.
I can also connect with SQL Developer Visual Studio's Server Explorer can see the database as well.
Upvotes: 0
Views: 237
Reputation: 4962
If you are using the Oracle.ManagedDataAccess
client you might want to set a path to the TNSnames file in your application.config file:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<oracle.manageddataaccess.client>
<version number="*">
<settings>
<setting name="TNS_ADMIN" value="C:\OracleTNS" />
</settings>
</version>
</oracle.manageddataaccess.client>
</configuration>
Upvotes: 1
Reputation: 678
I've found that instead of specifying a short name for the Data Source wherever your connection string is, just putting the whole connection description can solve issues like this. More of a work-around you can do if you don't want to chase down the specific configuration problem on the machine, but I haven't had it fail yet.
So if your TNSNames file has:
MYSID=
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = mydnshostname)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = MYSID)
)
)
and your connection string in web.config looks something like like this:
<connectionStrings>
<add name="MyConnection" connectionString="Data Source=MYSID;User ID=myUser;Password=myPassword;providerName="Oracle.DataAccess.Client" />
</connectionStrings>
you can do this instead in the configuration file:
<connectionStrings>
<add name="MyConnection" connectionString="Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST = mydnshostname)(PORT = 1521)))(CONNECT_DATA=(SERVICE_NAME = MYSID)));User ID=myUser;Password=myPassword;providerName="Oracle.DataAccess.Client" />
</connectionStrings>
Upvotes: 1