1

I have a table in an Oracle database and I passing one u_id parameter from my C# app to an Oracle stored procedure to retrieve data based on the u_id, but if is pass u_id value directly into my stored procedure and run it then it is retrieving the correct data, but whenever I pass an u_id value from my C# app and bind that data to a grid, then it is showing all the records from the table, you can check it in a screenshot below:

It is retrieving correct data in Oracle query:

Oracle query

but it is showing all the records on the page:

wrong data on the page

Oracle stored procedure:

create or replace procedure uspGetTrackByUID(u_id in varchar2,
                                         p_out out sys_refcursor) as
begin
    open p_out for
        select *
        from tblEmailTrack t
        where t.flag = 'R'
        and t.u_id = u_id;
end;

C# code:

private void OGetTrackByUID(string uid)
{
        connection();
        OracleCommand cmd = new OracleCommand("uspGetTrackByUID", ocon);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.AddWithValue("u_id", uid.Trim());
        cmd.Parameters.Add("p_out", OracleType.Cursor).Direction = ParameterDirection.Output;

        try
        {
            ocon.Open();
            grdTrack.EmptyDataText = "User haven't read the mail yet";
            grdTrack.DataSource = cmd.ExecuteReader();
            grdTrack.DataBind();
        }
        catch (Exception ex)
        {
            throw ex;
        }
        finally
        {
            ocon.Close();
            ocon.Dispose();
        }
}

What could be the issue?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Shreyas Pednekar
  • 177
  • 1
  • 3
  • 16

0 Answers0