DATA SET DOES NOT RETURN ROWS

Last post 04-18-2008 9:35 AM by yeotumitsu@sify.com. 3 replies.

Sort Posts:

  • DATA SET DOES NOT RETURN ROWS

    04-17-2008, 4:14 AM
    • Loading...
    • veobaretto
    • Joined on 04-20-2005, 5:16 AM
    • India
    • Posts 2

    Hi  

    I got an Oracle procedure which execute fine when execute it in toad, it returns all the rows, but when i execute it in .NET is does not return any rows. Find below the .NET code.

    DataLayerClass clsDataLayerClass;
    System.Data.OracleClient.
    OracleParameter
    [] arrOracleParameters;
    try
    {
    DataSet
    ds;
    clsDataLayerClass =
    new DataLayerClass
    (PUCon);
    arrOracleParameters =
    new System.Data.OracleClient.OracleParameter
    [5];
    arrOracleParameters[0] =
    new OracleParameter("P_SOURCE", OracleType
    .VarChar);
    arrOracleParameters[1] =
    new OracleParameter("P_BADGE_NBR", OracleType
    .VarChar);
    arrOracleParameters[2] =
    new OracleParameter("P_READ_FROM", OracleType
    .VarChar);
    arrOracleParameters[3] =
    new OracleParameter("P_READ_TO", OracleType
    .VarChar);
    arrOracleParameters[4] =
    new OracleParameter("P_REP_CURSOR", OracleType
    .Cursor);
    arrOracleParameters[0].Value = Source;
    arrOracleParameters[1].Value = BadgeNbr;
    arrOracleParameters[2].Value = ReadFrom;
    arrOracleParameters[3].Value = ReadTo;
    arrOracleParameters[4].Direction =
    ParameterDirection
    .Output;
    ds = clsDataLayerClass.GetDataset("CM_EMR_GET_METER_READS"
    , arrOracleParameters);
    return
    ds;
    }
    catch (Exception
    ex)
    {
    throw
    ex;
    }
    finally
    {
    clsDataLayerClass = null
    ;
    }
     
    //GETDATASET FUNCTION

    public DataSet GetDataset(string strCommandText, OracleParameter[] arrOracleParameters)
    {
    OracleCommand cmd = new OracleCommand
    ();
    try
    {
    cmd.CommandText = strCommandText;
    cmd.CommandType =
    CommandType
    .StoredProcedure;
    if ((arrOracleParameters == null) == false
    )
    {
    cmd.Parameters.AddRange(arrOracleParameters);
    }
    connObjOra.Open();
    cmd.Connection = connObjOra;
    OracleDataAdapter da = new OracleDataAdapter
    (cmd);
    DataSet ds = new DataSet
    ();
    da.Fill(ds);
    connObjOra.Close();
    da.Dispose();
    da =
    null
    ;
    return
    ds;
    }
    catch (Exception
    ex)
    {
    throw
    ex;
    }
    finally

    {
    if ((cmd == null) == false
    )
    {
    cmd.Dispose();
    cmd =
    null
    ;
    }
    }
    }
    --------------------------------------------------

     

    Any help would be appreciated 

    Regards

     

    Veo
  • Re: DATA SET DOES NOT RETURN ROWS

    04-17-2008, 10:07 AM
    • Loading...
    • johram
    • Joined on 06-13-2006, 10:36 AM
    • Sweden
    • Posts 3,352
    • Moderator

    Do you really need to return a cursor as output param? That might be the root of your problem. Wouldn't it be easier to just return the result set from the SP through a normal SELECT statement?

    If this post was useful to you, please mark it as answer. Thank you!
  • Re: DATA SET DOES NOT RETURN ROWS

    04-17-2008, 11:28 AM

    I dont see any obvious reason the code shouldnt work. 

    If you execute the same procedure in sqlplus, as the same user,  using the same bind values, does the ref cursor return rows? Here's how you can test that, just in case you didnt already know. 

    var P_SOURCE varchar2(50);
    var P_BADGE_NBR varchar2(50);
    var P_READ_FROM varchar2(50);
    var P_READ_TO varchar2(50);
    var rc refcursor;
    
    begin
    :P_SOURCE := '<insert value here>';
    :P_BADGE_NBR := '<insert value here>';
    :P_READ_FROM := '<insert value here>';
    :P_READ_TO := '<insert value here>';
    end;
    /
    set autoprint on
    exec CM_EMR_GET_METER_READS(:P_SOURCE,:P_BADGE_NBR,:P_READ_FROM,:P_READ_TO,:RC);
     
    Please "Mark as Answered" if this helped or resolved the issue for you.
  • Re: DATA SET DOES NOT RETURN ROWS

    04-18-2008, 9:35 AM

     I have answered it here.

    Hope it will help

     

    http://forums.asp.net/t/1247854.aspx 

    Hope it helps.

    -Manas

    =======================================
    If this post is useful to you, please mark it as answer.
Page 1 of 1 (4 items)
Microsoft Communities
Page view counter