Reputation: 956
I need to access a view on an oracle server with an ASP.NET website. It works if I debug the website through visual studio(press F5 in VS2012), but when I go to the version hosted on my local IIS (LocalHost/) I get this error:
Oracle.DataAccess.Client.OracleException: ORA-12154: TNS:could not resolve the connect identifier specified
A lot of the information I'm finding is related to the deprecated System.Data.OracleClient
and I'm using Oracle.DataAccess.dll
File version 4.112.3.0, Assembly version 2.112.3.0.
I set the AppPool it's running in to Enable 32-Bit Application=True
based on some other people with a similar issue, I think everything else is default settings.
I've tried using the gacutil to make sure it is installed in the gac.
I also made a small winForms application that works and can access the data.
I've tried a couple connection strings:
This one works:
"Data Source=SOURCE;Persist Security Info=True;Password=****;User Id=****;"
This one doesn't work, I can't figure out a valid SERVICE_NAME
:
"user id=****;password=****;data source=(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=****)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=****)));"
I always get this error:
Oracle.DataAccess.Client.OracleException: ORA-12514: TNS:listener does not currently know of service requested in connect descriptor
Places I've looked for SERVICE_NAME
I checked the connection I was able to establish with the first connection string and the SERVICE_NAME
was either blank or sys$users
depending on the query I ran.
I found three files named tnsnames.ora
; one was completely blank, the SERVICE_NAME
in the other two were Worker
and <database service name>
.
NOTE: I don't have access to the server, just credentials for this one view.
Upvotes: 1
Views: 1686
Reputation: 956
I found the SERVICE_NAME
with this: select sys_context('userenv','db_name') from dual;
and used the second connection string from the question:
"user id=****;password=****;data source=(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=****)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=****)));"
Thanks for all the help.
Upvotes: 1