0

I'm facing a problem that prevents me from continuing the C# development I'm in: I just can't use Oracle with my Visual Studio Community 2019 (it used to work OK with a 2015 version) on a C# application, though it works quite well on that same platform with a web application based on the same C# classes.

I must precise though that I haven't been developing for more than one year, so I fear I might have forgotten a very trivial thing, but though I've tried to find out I don't see what I may have forgotten.

Here's the facts:

. My development machine is called XWAD8044

. The domain has a server machine dedicated to Oracle and called ORA025

. The Oracle instance on that server is named ORA025 (same name as the server machine itself)

. I want to reach a schema called CARL, with password CARLPWD, created on the ORA025 instance,

. On the XWAD8044 machine, there is a TNSNAMES.ORA file containing the following instance:

ORA025 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = ORA025)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = ORA025)
    )
  )

All the following instructions work perfectly well on XWAD044:

ping ORA025 -> OK

tnsping ORA025 -> OK

sqlplus CARL/CARLPWD@ORA025 -> OK, SQLPLUS session starts on the CARL schema

select * from increments -> OK, all the lines of the CARL.INCREMENTS table are listed in the console.

So this proves that the connection between XWAD044 and ORA025 is fully operational.

Then I use the following string to open a connection:

User Id=CARL;Password=CARLPWD;Data Source=ORA025

in my application, I have referenced ORACLE.MANAGEDDATAACCESS.DLL (I just changed it from ORACLE.DATAACCESS.DLL that I've been using for years but that led yesterday to the same failure)

So the problem is that it seems the DLL doesn't want to work with the TNSNAMES.ORA, because when I try to open a connection on the CARL schema, I get the following error:

ORA-12504: TNS: listener was not given the Service_name in connect_data

It seems to me that this message proves that the Oracle DLL is well embedded by the C# process, otherwise I wouldn't get any message from the Oracle instance, but it seems that it doesn't use the TNSNAMES entry, since the SERVICE_NAME is given in the ORA025 entry.

Can someone please tell me how to solve this problem?

Thanks in advance.

BBBreiz
  • 543
  • 1
  • 5
  • 13
  • have you tried to set `TNS_ADMIN` in you c# program ? – Roberto Hernandez Sep 11 '21 at 10:45
  • Why don't you use `Oracle.DataAccess.Client`? Example of different methods: https://docs.oracle.com/database/121/ODPNT/featConnecting.htm#ODPNT199 I would suggest also to try "Using Easy Connect Naming Method" from them – Sayan Malakshinov Sep 11 '21 at 10:46
  • I do use Oracle.ManagedDataAccess.Client in my C# class (I formally used to declare Oracle.DataAccess.Client, but since it falied, I tried the new "managed" version). – BBBreiz Sep 11 '21 at 11:37
  • see https://stackoverflow.com/questions/28280883/determining-location-of-relevant-tnsnames-ora-file/28283924#28283924 - especially the link https://docs.oracle.com/cd/E63277_01/win.121/e63268/InstallManagedConfig.htm#ODPNT8161 – Wernfried Domscheit Sep 11 '21 at 20:02

1 Answers1

0

Welln I finally could make it through using the "EZconnect" way, by adding the server name to the instance name (the 2 names here are similar), so I replaced:

User Id=CARL;Password=CARLPWD;Data Source=ORA025

by:

User Id=CARL;Password=CARLPWD;Data Source=ORA025/ORA025

and that way, the Oracle.ManagedDataAccess.Client is finally able to find my Oracle server.

BBBreiz
  • 543
  • 1
  • 5
  • 13