I'm trying to connect to an Oracle Database 9.0.2 using OracleClient in C#.
I get the error "ORA-12154 Could not resolve service name" when trying to connect to the database.
I've checked the TNSNAMES.ora file an it seems ok.
The project where I get this error was previously a .VS 2003 project which I converted to a VS 2005 project.
As a test I created a small project in VS 2005 where I connected to the same Oracle database with the same connection parameters, and it worked fine.
Does anyone have a clue on what might be the problem

ORA-12154 error when connection to Oracle Database from C#
lsdhjroiwefjnwsd
I. some more common explaination for the above issue, I found on the web ...
System.Data.OracleClient requires Oracle client software version 8.1.7 or greater.
Problem
When usign System.Data.OracleClient with Oracle9i client, i got the following message while connecting to the Oracle database from and ASP.NET application.
System.Data.OracleClient requires Oracle client software version 8.1.7 or greater.
Cause
Security permissions were not properly set when the Oracle 9i Release 2 client was installed on Windows with NTFS. The result of this is that content of the ORACLE_HOME directory is not visible to Authenticated Users on the machine; this again causes an error while the System.Data.OracleClient is communicating with the Oracle Connectivity software from an ASP.NET using Authenticated User privileges.
Solution
To fix the problem you have to give the Authenticated Users group privilege to the Oracle Home directory.
JB Plum
This problem may occur if you had installed oracle earlier.
After spending more than a day, I figured that the final solution to this problem is to Reinstall Oracle client in a differnt folder
Instead of D:\oracle\ora92.. give any other path
mksql
Thank you for your reply.
I only have one instance of the tnsnames.ora file, and I only have the Oracle Client installed.
I'm still strugglig with this, but it seems to be related to only one of the projects in the solution.
When I set another project as startup project, there is no trouble connecting to the database and getting data in a datatable. But from this one project I get message as I mentioned before.
I'm quite clueless at this point. Any more Ideas
KirankumarC
Manu,
I tried to Re-start IIS but that did not help ... :(
To all others having this issue,
Now I tried to un-install Oracle Client 9.2 and re-install it
And later saw a new Error as mentioned below:
" System.Data.OracleClient requires Oracle client software version 8.1.7 or greater "
Then I was looking for ways to fix this issue and finally found one to solution ...
To FIX the above issue while using .Net 1.1 (VS 2003) & Oracle Client 9.2 (9i), to make an Oracle Connection from ASP .Net 1.1 Appliation (using System.Data.OracleClient.OracleConnection ) :: please do the following -
Soln:
1. Go to your MACHINE.CONFIG file (location: "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\CONFIG")
2. Search for text "<processModel" which is the process model Attributes section
3. In the processModel string, try to add user name as system ( userName="system" )
This worked miracles for me. 3 days of non-stop troubleshooting, finally found one solution :) ... Hope it helps you ...
Please drop your comments if the soln did help you ...
Ratna Kumar
If so you'll have to set up the tnsnames.ora on both HOMES.
Or else setup the registry.
Add string value TNS_ADMIN to \HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE
Set the values of TNS_ADMIN to the folder where the tnsnames.ora you set up resides.
Eg. C:\oracle\ora92\admin
FTAHARI
W.Randy
Hi Trond,
Did PJ's suggestion help you
Since the problem is project specific, I think you may try to recreate a new project and add the code block one by one to isolate the problem.
If you still have any concern, please feel free to post here.
Best regards,
Peter Huang
sinisterguy
I am having similar issues
I am trying to connect to Oracle9i from my .Net 1.1 Web App with the code block below ...
OracleConnection oracleConn =
new OracleConnection();oracleConn.ConnectionString = "User Id=abcdef;Password=xyz;Data Source=Ram_Dev";
oracleConn.Open()
I am using the following entry below in my TNSNAMES.ORA file
Ram_Dev =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP) (Host = oradb10) (Port = 1574))
)
(CONNECT_DATA =
(SID = oradev)
)
)
Now, let me explain where I stand ...
1. I am able to connect to the Oracle DB from my machine using PL/SQL developer ...
2. I am able to connect to the Oracle DB from .Net 1.1 when creating a WINDOWS Application
BUT
3. When I create a Web Application from .Net 1.1, it gives me the below mentioned error ...
" ORA-12154: TNS:could not resolve service name "
I have already tried various diff ways to fix this, but it has not been fruitful. Few things i already did (i) Given read and execute permissions for various users to the ORACLE dir, (ii) Made a TNS_ADMIN entry to the registry settings ORACLE with value to the C:/ORACLE/ora92/network/ADMIN
Kindly help. Have already spent 2 full days trying to fix this
Crypton
Philip Wright
My scenario is very much similar to the original post:
-SqlPlus works
-Toad works
-But using c# code and microsoft's OracleClient class does not work. Fails in code where I do "connection.Open()" with the ORA-12154 error.
What fixed the problem for me:
-Went to my %ORACLE_HOME%\NETWORK\ADMIN folder
-There was a SQLNET.ORA file in this folder. I simply removed it. Now all that this folder had was my TNSNAMES.ORA
Then my c# application worked.
PS: Also, I don't know if this makes a difference or not, but I happenned to copy over my TNSNAMES.ORA into the
%ORACLE_HOME%\NETWORK\ADMIN\SAMPLES folder as well (overwriting the default tnsnames.ora file that comes with the installation). I also left the SQLNET.ORA file in the SAMPLES folder untouched.
Hope this helps folks !
mrangel
Hey Ram,
Did you restart the IIS. Try doing that.
Manu
santosh wgl
guys
even I have an application on vs2003 which gives the same error. I am able to connect to the db using sql+ but the application is not able to do so. I developed another application to check on this and is connecting. Any suggestions on what the problem might be.