Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When using an OracleCommand in .net must the OracleClient be installed on the machine or does .net cover this?

I want to make a simple query on an Oracle database from .net using similar code to this.

using System;
using System.Data;
using Oracle.DataAccess.Client;

class Sample
{
    static void Main()
    {
        // Connect to Oracle
        string constr = "User Id=scott;Password=tiger;Data Source=AKI1.WORLD";
        OracleConnection con = new OracleConnection(constr);
        con.Open();

        // Display Version Number
        Console.WriteLine("Connected to Oracle " + con.ServerVersion);

        // Read REF CURSOR into DataSet
        DataSet ds = new DataSet();
        OracleCommand cmd = con.CreateCommand();

        cmd.CommandText = "GetComplexTabPkg.GetEmp";
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.Add("p_dep", OracleDbType.Int16).Value = 20;
        cmd.Parameters.Add("p_ref", OracleDbType.RefCursor).Direction
             = ParameterDirection.Output;

        OracleDataAdapter da = new OracleDataAdapter(cmd);
        da.TableMappings.Add("Emp", "Emp");
        da.Fill(ds);

        // Close and Dispose OracleConnection
        con.Close();
        con.Dispose();

        // Show Message
        Console.WriteLine("DataSet filled");
    }
}

My only concern is does the Oracle Client need to be installed on the web server that is running this code? It's my first time using this and I would like to avoid any obvious issues that can be prevented. Thanks.

like image 720
gsirianni Avatar asked Nov 24 '25 14:11

gsirianni


1 Answers

Yes, Oracle Client need to be installed in web server. The work around will be to ship your application with Instant Oracle Client

like image 109
Emmanuel N Avatar answered Nov 26 '25 04:11

Emmanuel N



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!