0

I am newly with c# MVC that passing param value to oracle PROCEDURE. It is possible to declare param set both input and output from db? that currently my code:

 public string get_data(out string send_get)

 cmd.Parameters.Add("send_get", OracleDbType.Varchar2).Direction = ParameterDirection.InputOutput;

Am i right with this param declaration? If anyone have experience with it please kindly help me please. thanks in advance

  • You would be better off with creation of separate `OracleParameter` object and then using the object to set various properties, before adding that to the Parameter Collection – Mrinal Kamboj Sep 03 '18 at 06:13

1 Answers1

0

If you try the following:

cmd.Parameters.Add("send_get", OracleDbType.Varchar2).Direction = ParameterDirection.InputOutput;

you will get a warning "SqlParameterCollection.Add is obsolete and deprecated". You can use AddWithValue.

Or you can use this as well:

OracleParameter par = new OracleParameter("@param1", OracleDbType.Varchar2, 250);
par.Direction = ParameterDirection.InputOutput;
par.Value = "Foo";
cmd.Parameters.Add(par);

For deprecated method Add refer to this SO:

SqlCommand Parameters Add vs. AddWithValue

Gauravsa
  • 6,330
  • 2
  • 21
  • 30