VB.NET: Unable to connect to an Oracle database server from client app

4.6k views Asked by At

I have 2 laptops (A and B) on the same local networks (Wi-Fi).

I have installed Oracle database 12c r2 on laptop A.

In laptop A I have created a VB.NET application with Visual Studio 2017 that can connect to the Oracle database.

The app works fine on laptop A. It connects to the database and this is my app form, and the connection string I use (192.168.20.98 is my laptop A IP Address):

App working screen, from laptop A

oracle_connection = New OracleConnection(
    "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=" & protocol.Text &
    ")(HOST=" & host.Text & ")(PORT=" & port.Text &
    ")))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=" & db_name.Text &
    ")));User Id=" & user_id.Text & ";Password=" & pswd.Text)

I've also edited my listener.ora and tnsnames.ora located in C:\app\mustafa\product\12.2.0\dbhome_1\network\admin as the following:

listener.ora:

# listener.ora Network Configuration File: 
C:\app\mustafa\product\12.2.0\dbhome_1\network\admin\listener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = CLRExtProc)
(ORACLE_HOME = C:\app\mustafa\product\12.2.0\dbhome_1)
(PROGRAM = extproc)
(ENVS = 
"EXTPROC_DLLS=ONLY:C:\app\mustafa\product\12.2.0\dbhome_1\bin\oraclr12.dll")
)
)

LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.20.98)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)

tnsnames.ora:

# tnsnames.ora Network Configuration File: 
C:\app\mustafa\product\12.2.0\dbhome_1\network\admin\tnsnames.ora
# Generated by Oracle configuration tools.

DB1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.20.98)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = db1)
)
)

LISTENER_DB1 =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.20.98)(PORT = 1521))


ORACLR_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
(CONNECT_DATA =
(SID = CLRExtProc)
(PRESENTATION = RO)
)
)

I've edited my Oracle home folder permission to give authenticated users the full access.

So when I move my app to the laptop B and run it to connect to the database on laptop A I got this error:

System.Data.OracleClient requires Oracle client software version 8.1.7 or greater.

Error screen from laptop B

I can't find any solution. Does it require the Oracle database 12c r2 to be installed on my laptop B too?

1

There are 1 answers

1
Pedro Gaspar On BEST ANSWER

The System.Data.OracleClient namespace is the .NET Framework Data Provider for Oracle, but still it needs the Oracle Client software installed on the target machine:

Oracle and ADO.NET | Microsoft Docs

The .NET Framework Data Provider for Oracle provides access to an Oracle database using the Oracle Call Interface (OCI) as provided by Oracle Client software.

And:

.NET Framework Data Providers | Microsoft Docs

For Oracle data sources. The .NET Framework Data Provider for Oracle supports Oracle client software version 8.1.7 and later, and uses the System.Data.OracleClient namespace.

But, as stated on the docs also:

Note

The types in System.Data.OracleClient are deprecated. The types remain supported in the current version of.NET Framework but will be removed in a future release. Microsoft recommends that you use a third-party Oracle provider.

So, it's better to use the Oracle Data Provider for .NET (ODP.NET), instead of the deprecated System.Data.OracleClient. Here there's a 3 steps migration article to help in the proccess.

Anyway, both the Microsoft or Oracle data providers will still require the Oracle Client software installed on the target machine. The Oracle Client software is named Oracle Instant Client and can be found here.

If you already have the Oracle Instant Client installed on the target machine, you could try one of these (that I think the question's author already did):