I canโt believe that I need to ask this question, but I canโt let my life connect to the Oracle 11g database.
When using System.Data.OracleClient , the following is true, but obviously this is depreciating. When using the same code, but using Oracle.DataAccess.OracleClient , I get the following error:
{"ORA-12545: Connect failed because target host or object does not exist"}
Here is my code
using (OracleConnection con = new OracleConnection("Data Source=orac;User Id=SYSTEM; Password=Pass;")) { con.Open(); Console.WriteLine("Connection opened"); OracleCommand cmd2 = new OracleCommand("SELECT * FROM SYSTEM.TABLE", con); OracleDataReader oracleDataReader = cmd2.ExecuteReader(); while (oracleDataReader.Read()) { Console.WriteLine(oracleDataReader[0]); } }
Can someone help me with what I am doing wrong?
I had to change the program to 32 bits to download Oracle.DataAccess.dll .
Is this even the right library?
thanks
EDIT
tnsnames.ora file as follows:
# tnsnames.ora Network Configuration File: C:\app\UserName\product\11.2.0\dbhome_3\network\admin\tnsnames.ora
UPDATE
I tried to connect using the Oracle Sql developer. This works as long as I use the TNS connection type, but it does not work if I use the basic connection type.
I also noticed that in my services there are 2 names
OracleOraDb11g_home1TNSListener OracleOraDb11g_home2TNSListener
Orac dbhome is home3 I think this could be a problem? If so does anyone know how I can fix this?
thanks
UPDATE HKEY_LOCAL_MACHINE \ SOFTWARE \ ORACLE \ has two properties (default) and inst_loc. There are several folders, two of which are called "KEY_OraDb11g_home1" and "KEY_OraDb11g_home2", both of which contain the ORACLE_HOME property, which they:
KEY_OraDb11g_home1 - ORACLE_HOME = C: \ app \ UserName \ product \ 11.2.0 \ dbhome_2 KEY_OraDb11g_home2 - ORACLE_HOME = C: \ app \ UserName \ product \ 11.2.0 \ dbhome_3
The SID for Db in home1 is something called OracleDev, maybe I installed it at some point a long time ago, but I certainly donโt need it now if it causes a problem
thanks