1

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.

7
  • 1
    are you aware that you do not need to create your datasource that way.. we currently use Oracle 11.x and we installed the oracle client 32 and 64 bit version and when connecting we use the same construct like how we connect to Sql Server if you must do it using TNS Names make sure that the TNS Names file is located on the machine look at this link as well C# Connection Strings Oracle DB Commented Oct 9, 2015 at 22:25
  • I tried a string similar to that (see the first one). it works in the desktop application and if I run the website in debug mode through visual studio. if I go to the website at localhost in a browser I get the first error. I only tried the second connection string after searching for a solution to the initial error. Commented Oct 9, 2015 at 23:19
  • 1
    you need to have that Oracle Client installed on the remote location find yourself a DBA or someone whom has admin experience when it comes to setting up and or Installing Oracle Client on Remote host.. Commented Oct 9, 2015 at 23:21
  • 1
    Eww. Don't use any Oracle library that requires you to install the Oracle Client. That's just a headache. Instead, use the Oracle Managed Driver. It has no external dependencies. Then go to connectionstrings.com and use the "Omitting TNSNAMES.ORA" style connection string. Commented Oct 10, 2015 at 5:20
  • 1
    I had the same issue in our current environment ..that's how we discovered that the .NET dll for Oracle 64bit had issues.. but we were able to change our build to use 32bit vs AnyCpu.. Commented Oct 10, 2015 at 19:46

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.