C# connecting to Oracle database

oracle United States
  • 17 years ago

    Can any body copy me a sample code that could connect to an Oracle database & the requirements compile, if any.
    I am trying to use this code, it compiles but gives a run time error Unhandled Exception: System.Security.SecurityException: Security error.
      at MyAdo..ctor()
      at MyAdo.Main()


    any suggestions ...!?


    CODE:::
    // created on 3/6/2003 at 1:49 PM
    //To Compile: >csc /rystem.Data.OracleClient.dll oracle.cs


    using System;
    using System.Data;
    using System.Data.OracleClient;


    public class MyAdo {
       OracleConnection conn;
       //OracleCommand command;
       //OracleDataReader reader;
       //string query="";
       
       public MyAdo() {
           Console.WriteLine("In MyAdo");
           try
           {
               conn = new OracleConnection("data source=bvdev;user id=boatdev;password=boatdev");
               conn.Open();
           }
           catch(System.Security.SecurityException e1)
           {
               Console.WriteLine("Error in connecting ...");
           }
           catch(Exception e)
           {
               Console.WriteLine("Error in connecting ...");
           }
           
       }
       
       public static void Main(){
           Console.WriteLine("In main");
           new MyAdo();
       }
    }


Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Debugging is anticipated with distaste, performed with reluctance, and bragged about forever.” - Dan Kaminsky