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
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
None
0 Points
9 Posts
How to pass two or more Parameter inside foreach loop
Jan 22, 2018 08:01 AM|sarumathi vikraman|LINK
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
Star
9831 Points
3120 Posts
Re: How to pass two or more Parameter inside foreach loop
Jan 23, 2018 03:04 AM|Brando ZWZ|LINK
Hi Sarumathi vikraman,
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.
2.ASP.NET codes:
Best Regards,
Brando