0

I am new to C# and trying to connect to an Oracle database in a simple piece of code. I have been getting a lot of connection errors and have tried to solve them through Google search and solved them.

I am now at a point that I am getting an error at the conn.Open(); statement:

An unhandled exception of type 'Oracle.DataAccess.Client.OracleException' occurred in Oracle.DataAccess.dll

Additional information: External component has thrown an exception.

I don't know what this error means. I tried and searched a lot but couldn't find anything for this.

Code :

string connection_string = "Data Source=localhost;Persist Security Info=True;User ID=system;Password=6677";
OracleConnection conn = new OracleConnection(connection_string);
conn.Open();

I also tried many other connection_string including

Data Source=(DESCRIPTION =" + "(ADDRESS = (PROTOCOL = TCP)(HOST =localhost)(PORT = 1521))" + "(CONNECT_DATA =" + "(SERVER = DEDICATED)" + "(SERVICE_NAME = XE)));" + "User Id=system;Password=6677;"

Nothing worked.

The Main Error Window

Libraries

Environment Variables

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

2 Answers2

1

According to your %PATH% you really messed up your Oracle installations.

Remove all of them properly (see How to uninstall / completely remove Oracle 11g (client)?) and make one fresh installation. If you need the 32-bit and 64-bit Client follow this one: BadImageFormatException. This will occur when running in 64 bit mode with the 32 bit Oracle client components installed

Wernfried Domscheit
  • 54,457
  • 9
  • 76
  • 110
0

This can be lot of different things.

  1. Try with anohter user "system" is an internal user and has SYSDBA privilege. Can you try adding a new user:

CREATE USER test IDENTIFIED BY test;

and connect with this connection string:

"SERVER=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=XE)));uid=test;pwd=test;"

(you can take a look here for different connection strings)

  1. Double check that your client installation. In you screenshot of you environment variable you seems to have 2 clients installed: a 32 and 64 bits. Remove the 32 bits environment variable if your using a 64 bits DLL in your project.
SuperPoney
  • 563
  • 6
  • 21
  • Can you guide where do I add a new user please.? I am a newbie in this :- 2. Yes if I just installed the 32 bit clients as removing them gave me an ora-12154 error and solution to this was to keep both clients – Tiger Strom Nov 20 '20 at 16:52
  • The instruction to create a new user is in my answer: connect with sqlplus or sqldeveloper to you XE database and use the following instruction `CREATE USER test IDENTIFIED BY test;` – SuperPoney Nov 20 '20 at 16:53
  • I tried creating new user and tested with some other connection_strings too.Didn't worked in this case – Tiger Strom Nov 20 '20 at 17:00