Quantcast
Channel: Oracle, MySQL, Sybase, Informix and other databases
Viewing all articles
Browse latest Browse all 1350

Wrong number of arguments error while calling Oracle stored procedure from ASP.NET

$
0
0

Hi,

 I use to get the data in Oracle Sql Developer , but when I am executing the procedure from ASP.NET application it throws error as Wrong Number of arguments.

ASP.NET C#:

public DataTable Execute2DataTableoraclesp()
    {
        DataTable dt = new DataTable();
        OracleConnection conn = null;
        try
        {

            conn = new OracleConnection(oradb);

                conn.Open();
           
            OracleCommand cmd = new OracleCommand();
            OracleDataAdapter da = new OracleDataAdapter("sp_procedure", conn);
            cmd.Connection = conn;
            cmd.CommandText = argQuery;
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("p_recordset", OracleType.NVarChar,2000).Direction = ParameterDirection.Output;
            cmd.ExecuteNonQuery();

            da.Fill(dt);
            return dt;
        }

        catch (Exception ex)
        {
            return dt;

        }
        finally
        {
            conn.Close();
        }

Procedure In Oracle:

create or replace PROCEDURE sp_procedure(p_recordset OUT SYS_REFCURSOR)
AS 
BEGIN 
  OPEN p_recordset FOR
    select count(*) as totalcalls,to_date(max(datetime1)) as STARTDATE, to_date(min(DATETIME1)) as  CURRENTDATE  from tablename;
END sp_procedure;


Viewing all articles
Browse latest Browse all 1350

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>