locked
How to pass two or more Parameter inside foreach loop RRS feed

  • Question

  • User708405960 posted

    Hi Everyone,

    In ASP.NET c# web service I would like to pass two or more parameters I don't know how to achieve this, someone please help me out to resolve this.

    I'm using Oracle DB and the stored procedure and here is my sample code

    OracleParameter childretval = new OracleParameter("P_RECORDSET", OracleDbType.RefCursor);
    childretval.Direction = ParameterDirection.ReturnValue;

    var childParameters = new OracleParameter[2];
    childParameters[0] = childretval;
    childParameters[3] = new OracleParameter {
    Direction=ParameterDirection.Input,
    Value=dr["IDNUMBER"],
    OracleDbType= OracleDbType.Varchar2,
    Size=100,
    ParameterName = "P_ACCOUNT_ID",
    //startdate="P_START_DATE"

    //Enddate="P_END_DATE"

    };

    I would like to pass these 3 parameters.(ParameterName,start date,End date)

    Thanks in advance

    Monday, January 22, 2018 8:01 AM

All replies

  • User283571144 posted

    Hi Sarumathi vikraman,

    In ASP.NET c# web service I would like to pass two or more parameters I don't know how to achieve this, someone please help me out to resolve this.

    I'm using Oracle DB and the stored procedure and here is my sample code

    According to description, I suggest you could refer to below codes to know how to pass multiple parameters to Oracle DB  stored procedure.

    1.The stored procedure.

    create or replace procedure count_emp_by_dept(pin_deptno number, pout_count out number)
    is
    begin
     select count(*) into pout_count
     from scott.emp
     where deptno=pin_deptno;
    end count_emp_by_dept;

    2.ASP.NET codes:

                using (OracleConnection objConn = new OracleConnection("Data Source=ORCL; User ID=scott; Password=tiger"))
                {
                    OracleCommand objCmd = new OracleCommand();
                    objCmd.Connection = objConn;
                    objCmd.CommandText = "count_emp_by_dept";
                   objCmd.CommandType = CommandType.StoredProcedure;
                    objCmd.Parameters.Add("pin_deptno", OracleDbType.Int32).Value = 20;
                    objCmd.Parameters.Add("pout_count", OracleDbType.Int32).Direction = ParameterDirection.Output;
                    try
                    {
                        objConn.Open();
                        objCmd.ExecuteNonQuery();
                        System.Console.WriteLine("Number of employees in department 20 is {0}", objCmd.Parameters["pout_count"].Value);
                    }
                    catch (Exception ex)            
                    {
                        System.Console.WriteLine("Exception: {0}", ex.ToString());
                    }
                    objConn.Close();
                }

    Best Regards,

    Brando

    Tuesday, January 23, 2018 3:04 AM