0

I have installed Oracle 11g and Oracle 12c database in my machine, tried to access Oracle 12c database through console application using c# and am unable to connect it; at the same time I can able to connect Oracle 11g database.

Through the command prompt I can able to connect Oracle 12c database by executing SQL/plus commands.

Do I need to change or add any connection parameter in connection string to connect Oracle 12c data base?

Is there any way to connect Oracle12c database through console application by adding any libraries?

Here is my code sample:

string connectionString = "Data Source=localhost;User ID=system;Password=pwd";
using (OracleConnection connection = new OracleConnection()) 
{
   connection.ConnectionString = connectionString;
   connection.Open();
}

This code connects Oracle 11g database. How can I achieve the same connection to the Oracle 12c database?

MT0
  • 143,790
  • 11
  • 59
  • 117
Umapathy S
  • 220
  • 2
  • 17
  • Did you read http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/hol08/dotnet/getstarted-c/getstarted_c_otn.htm ? – BugFinder Feb 02 '17 at 10:07
  • 1
    Can you connect to 12c in the command prompt using the TNS listener? Use something like `sqlplus /@localhost/service_name AS sysdba` If that fails then the TNS listener may not be running for 12c (and may have a conflict with the 11g listener). – MT0 Feb 02 '17 at 10:11
  • To check TNS listener i have entered sqlplus /@localhost/service_name AS sysdba this command in command prompt and i am getting error message like ERROR: ORA-12514: TNS:listener does not currently know of service requested in connect descriptor. Then it prompts for User name and Password, after providing this getting message like connected with Oracle database 12c Enterprise edition. – Umapathy S Feb 02 '17 at 10:35
  • I think you'll need to specify the SID or service name of the database you want to connect to. – Tanner Swett Feb 02 '17 at 13:02
  • @UmapathyS You need to change `service_name` to whatever the service name of your Oracle instance is - see [How to find Oracle Service Name](http://stackoverflow.com/q/22399766/1509264). – MT0 Feb 02 '17 at 14:30
  • Yes. After adding the SID or service name in connection string can able to establish the connection between client and server. Thank you all. – Umapathy S Feb 03 '17 at 05:39

0 Answers0