locked
Two Output from store Procedure How to Separate two output in dataset? RRS feed

  • Question

  • User-410257276 posted
     OracleConnection SelectConnection = new OracleConnection(GlobalConnection.OracleConnectionString);
            string Routecode = ddlroutecode.SelectedItem.Text;
            OracleCommand SelectCommand = new OracleCommand();
            OracleCommand SelectCommand1 = new OracleCommand();
            SelectConnection.Open();
            SelectCommand.Connection = SelectConnection;
            SelectCommand.CommandText = "SP_GRID_PICKUP";
            SelectCommand.Parameters.Add("Pincode_No", OracleDbType.Varchar2).Value = Routecode;
            SelectCommand.Parameters.Add("All_Details", OracleDbType.RefCursor).Direction = ParameterDirection.Output;
            SelectCommand.Parameters.Add("Messeger_Name", OracleDbType.RefCursor).Direction = ParameterDirection.Output;
            SelectCommand.CommandType = CommandType.StoredProcedure;
            OracleDataAdapter SelectAdapter = new OracleDataAdapter(SelectCommand);
            DataSet Grdset = new DataSet();
            SelectAdapter.Fill(Grdset,"Table");
            SelectAdapter.Fill(Grdset, "Table1");
            if(Grdset.Tables.Count>0)
            {
                grdpickup.DataSource = Grdset;
                grdpickup.DataBind();
            }
            else
            {
    
            }
    

    This is my code ......

    I am written Two Select Command from different table in one store Procedure. And i send the two data in output parameter i mentioned above in code.

    Here i want know to how to separate the two output in dataset?

      i am getting the value from Table and Table1....

    I tried above but no use Please Tell if any Knows....

     

    Friday, April 29, 2016 11:04 AM

Answers

  • User-1377768212 posted

    Hi,

    You can retrieve the two tables inside the stored procedure like this :

     DataTable tableA = Grdset.Tables[0];
     DataTable tableB = Grdset.Tables[1];

    Try this code :

    Check this example , Properly check the if condition in your code.

    OracleConnection SelectConnection = new OracleConnection(GlobalConnection.OracleConnectionString);
            string Routecode = ddlroutecode.SelectedItem.Text;
            OracleCommand SelectCommand = new OracleCommand();
            OracleCommand SelectCommand1 = new OracleCommand();
            SelectConnection.Open();
            SelectCommand.Connection = SelectConnection;
            SelectCommand.CommandText = "SP_GRID_PICKUP";
            SelectCommand.Parameters.Add("Pincode_No", OracleDbType.Varchar2).Value = Routecode;
            SelectCommand.Parameters.Add("All_Details", OracleDbType.RefCursor).Direction = ParameterDirection.Output;
            SelectCommand.Parameters.Add("Messeger_Name", OracleDbType.RefCursor).Direction = ParameterDirection.Output;
            SelectCommand.CommandType = CommandType.StoredProcedure;
            OracleDataAdapter SelectAdapter = new OracleDataAdapter(SelectCommand);
            DataSet Grdset = new DataSet();
            SelectAdapter.Fill(Grdset);
            DataTable tableA = Grdset.Tables[0];
            DataTable tableB = Grdset.Tables[1];
            if(Grdset.Tables[0].Count>0)
            {
                grdpickup.DataSource = Grdset;
                grdpickup.DataBind();
            }
            else
            {
    
            }

    Reference :

    http://stackoverflow.com/questions/7239450/returning-multiple-tables-from-a-stored-procedure

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, April 29, 2016 12:16 PM

All replies

  • User-1377768212 posted

    Hi,

    You can retrieve the two tables inside the stored procedure like this :

     DataTable tableA = Grdset.Tables[0];
     DataTable tableB = Grdset.Tables[1];

    Try this code :

    Check this example , Properly check the if condition in your code.

    OracleConnection SelectConnection = new OracleConnection(GlobalConnection.OracleConnectionString);
            string Routecode = ddlroutecode.SelectedItem.Text;
            OracleCommand SelectCommand = new OracleCommand();
            OracleCommand SelectCommand1 = new OracleCommand();
            SelectConnection.Open();
            SelectCommand.Connection = SelectConnection;
            SelectCommand.CommandText = "SP_GRID_PICKUP";
            SelectCommand.Parameters.Add("Pincode_No", OracleDbType.Varchar2).Value = Routecode;
            SelectCommand.Parameters.Add("All_Details", OracleDbType.RefCursor).Direction = ParameterDirection.Output;
            SelectCommand.Parameters.Add("Messeger_Name", OracleDbType.RefCursor).Direction = ParameterDirection.Output;
            SelectCommand.CommandType = CommandType.StoredProcedure;
            OracleDataAdapter SelectAdapter = new OracleDataAdapter(SelectCommand);
            DataSet Grdset = new DataSet();
            SelectAdapter.Fill(Grdset);
            DataTable tableA = Grdset.Tables[0];
            DataTable tableB = Grdset.Tables[1];
            if(Grdset.Tables[0].Count>0)
            {
                grdpickup.DataSource = Grdset;
                grdpickup.DataBind();
            }
            else
            {
    
            }

    Reference :

    http://stackoverflow.com/questions/7239450/returning-multiple-tables-from-a-stored-procedure

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, April 29, 2016 12:16 PM
  • User-410257276 posted

    Thanks for your reply...

    Its working fine

    Monday, May 2, 2016 5:37 AM