1

I have a database in oracle 11 g express edition. I have installed ODCA (ODAC121012Xcopy_32bit) in my local machine. I am trying to connect to the oracle db from a simple console c#.net application. My c# code looks like this -

using System;
using Oracle.DataAccess.Client;

namespace ClassLibrary3
{
     public class Class1
     {
         public static void Main(String[] args)
         {
               string host = "10.237.209.126";

               string connStr = "Data Source=(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP) (HOST = " + host + ")(PORT = " + 1521 + "))(CONNECT_DATA = (SERVER = DEDICATED)(SERVICE_NAME = " + "edcadmin" + ")));Password=" + "edcadmin" + ";User ID=" + "edcadmin";
               OracleConnection conn = new OracleConnection();
               conn.ConnectionString = connStr;

               try
               {
                    conn.Open();
               }
               catch (Exception ex)
               {
                    Console.WriteLine(ex.ToString());
               }

              Console.ReadLine();
         }
     }
 }

The host is a 32 bit machine and it has windows 2008 server installed.

When I run this program I get an exception like this

Oracle.DataAccess.Client.OracleException
     at Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, String procedure, Boolean bCheck, Int32 isRecoverable)
     at Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, Object src)
     at Oracle.DataAccess.Client.OracleConnection.Open()
     at ClassLibrary3.Class1.Main(String[] args)

I have checked the connection string multiple times, it is correct one. I installed SQLDeveloper and I could see my database edcadmin with the userId and password edcadmin, edcadmin respectively.

I have spent lot of time trying to figure out what is going wrong. Any help will be highly appreciated.

Edit : Here is the screen shot of the exception

enter image description here

6
  • What is the ex.Message? Commented Oct 24, 2014 at 7:31
  • Did you install the right Oracle client tools? Commented Oct 24, 2014 at 8:16
  • In your catch block, you should write ex.Message to the console, instead of the exception itself. It will contain an Oracle error code ("ORA-xxxxx") which would be a big help. Commented Oct 24, 2014 at 8:24
  • @Rik I have included the exception details Commented Oct 24, 2014 at 8:30
  • @PatrickHofman I have installed the instant client coming with ODCA. Commented Oct 24, 2014 at 8:32

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.