Click here to Skip to main content
15,900,724 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have created one windows service to get the data from oracle table
i have mentioned the Connection string in app.config file and its correct
while connection im getting error as
TNS:could not resolve service name

i checked for the ora note pad file for the service name it is correct bt still im getting this error
please suggest solution

What I have tried:

getting error at following point

public OracleConnection ConnectDB(OracleConnection dbConnection)
      {
          try
          {
              if (dbConnection.State != ConnectionState.Open)
              {
                  dbConnection.Open();
              }
              return dbConnection;
          }
          catch (DbException exp)
          {
              return null;
          }
      }
Posted
Updated 22-Feb-17 10:00am
Comments
j snooze 20-Feb-17 17:28pm    
so you checked your TNSNames.ora file? The entry for the name in there is the exact one you use?

You could also do something like this(brackets [] around the stuff you need to fill in). I'm also assuming the default port of 1521.

Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=[ORACLE SERVER HOSTNAME OR IP])(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=[YOUR TNS SERVICE NAME])));User Id=[YOURUSERID];Password=[YOURPASSWORD];

Have you tried connecting using something like Oracle SQL Developer, PL/SQL or Toad? Just to make sure the oracle service listener is running?
Member 12966735 15-Mar-17 2:37am    
I have replace the Data source to full address as you said but now im getting error ORA-06413: Connection not open.
i have search for the solution and found one but i dont understand can someone plz explain it below is the solution

First you can change the connection string to expand out the tns entry:

Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=10.161.50.101)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=MOUAT)));Password=password;User Id=username;

Then you get the real error:

And got ‘ORA-06413: Connection not open.’

Which was due to the 'Windows Service' path having brackets in it '(DEV)' or '(UAT)'

i dont understand this Answer
ANSWER: Expand out the connection string to exclude the TNS resolution and then make sure that the path to the calling application does not contain brackets '(' or ')'.

1 solution

Please, follow the steps provided on this site: ORA-12150 to ORA-12236[^]
Further instruction you'll find here: odbc - Oracle ORA-12154: TNS: Could not resolve service name Error? - Stack Overflow[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900