Error when trying to fill Datagrid from Oracle stored proc

Last post 05-16-2008 1:45 AM by yeotumitsu@sify.com. 1 replies.

Sort Posts:

  • Error when trying to fill Datagrid from Oracle stored proc

    05-14-2008, 12:08 PM
    • Loading...
    • Scotty_M
    • Joined on 03-12-2008, 4:45 PM
    • Posts 10

    On an ASP.NET form I'm trying to populate a data grid with the following oracle codebehind code:

    Dim Oraclecon As New OracleConnection("Data Source=####;User Id=####;Password=####;Integrated Security=no;")
    Oraclecon.Open()
    Dim myCMD As New OracleCommand()
    myCMD.CommandType = CommandType.StoredProcedure
    myCMD.Connection = Oraclecon
    myCMD.CommandText = "####"
    myCMD.Parameters.Add(New OracleParameter("parm1", OracleType.Char)).Value = "####"
    myCMD.Parameters.Add(New OracleParameter("parm2", OracleType.VarChar)).Value = "####"
    myCMD.Parameters.Add(New OracleParameter("parm3", OracleType.VarChar)).Value = "####"
    myCMD.Parameters.Add(New OracleParameter("parm4", OracleType.Char)).Value = "####"
    myCMD.Parameters.Add(New OracleParameter("parm5", OracleType.VarChar)).Value = "####"
    myCMD.Parameters.Add(New OracleParameter("out_cursor", OracleType.Cursor)).Direction = ParameterDirection.Output
    Dim oraDA As New OracleDataAdapter()
    oraDA.SelectCommand = myCMD
    Dim dt As New DataTable

    oraDA.Fill(dt)
    DataGrid1.DataSource = dt
    DataGrid1.DataBind()

    I'm getting an error when doing the oraDA.Fill(dt): ORA-08103: object no longer exists.

    Please help!

    Thanks,

     Scotty

     

  • Re: Error when trying to fill Datagrid from Oracle stored proc

    05-16-2008, 1:45 AM

    What I have got from this post is that you may have some problem with this line of code -  

    Scotty_M:
    myCMD.Parameters.Add(New OracleParameter("out_cursor", OracleType.Cursor)).Direction = ParameterDirection.Output
     

    Try this -

    ===============================================

    try
            {
                string strconn = "whatEverConnectStr";
                OracleConnection conn = new OracleConnection(strconn);
                OracleCommand objCmd = new OracleCommand();
                objCmd.Connection = conn;
                objCmd.CommandText = "getAllCity";
                objCmd.CommandType = CommandType.StoredProcedure;
                objCmd.Parameters.Add("p_recordset", OracleType.Cursor).Direction = ParameterDirection.Output;
                OracleDataAdapter odr = new OracleDataAdapter(objCmd);

                DataSet ds = new DataSet();
                odr.Fill(ds);
                GridView1.DataSource = ds.Tables[0];
                           
                GridView1.DataBind();
             
              
            }
            catch (Exception ex)
            {
                string excep = ex.Message;
            }

    =================================================   

    Make sure the name of output parameter ( p_recordset in this case) is same in code and in stored proc.

    =================================================

    Sample SP - 

    create or replace
    PROCEDURE GETALL
    (
    p_recordset OUT types.cursor_type
    )

    /*
    Created By : Manas
    */

    AS
    BEGIN
    OPEN p_recordset FOR
    select col1,col2 from tablename;
    END GETALL;
     

    =======================================

    types.cursor_type is -

    create or replace
    PACKAGE Types AS

                TYPE cursor_type IS REF CURSOR;

                END Types;

    ==============================================


     

    Hope it helps.

    -Manas

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