Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8435857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:01:58+00:00 2026-06-10T07:01:58+00:00

I have Stored Procedure which returns Multiple tables as ResultSet. I Stored it in

  • 0

I have Stored Procedure which returns Multiple tables as ResultSet. I Stored it in DataTable and Pass that DataTable Object to Another Form Which Print Tables In MY Web Page.
My Question is How Can i Stored Multiple ResultSet Returned from Stored Procedure into SINGLE DataTable Object Which I Can return to another function.

    public static DataTable[] getGraphData(Int32 type)
{
    SqlConnection oConn = null;
    DataSet dsReturn = null;
    DataTable[] dtReturn=new DataTable[2];
    try
    {
        getConnection(ref oConn, 1);

        using (SqlStoredProcedure sspObj = new SqlStoredProcedure("dbo.usp_getGraphData", oConn, CommandType.StoredProcedure))
        {
            sspObj.AddParameterWithValue("@Type", SqlDbType.Int, 0, ParameterDirection.Input, type);
            dsReturn = sspObj.ExecuteDataSet();
            dtReturn[0] = dsReturn.Tables[0];
            dtReturn[1] = dsReturn.Tables[1];
            dtReturn[2] = dsReturn.Tables[2];
            sspObj.Dispose();
        }
        closeConnection(ref oConn);
    }
    catch (Exception xObj)
    {
        //dtReturn[] = new DataTable();
    }
    return dtReturn;
}

Function Which Takes the all three DataTables

DataTable dtOutput = Generix.getGraphData(type);

How to get Each DataTable From Here ? Means 0th Element to dtOutput1 , 1st Element to dtOutput2…..Like wise

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T07:01:59+00:00Added an answer on June 10, 2026 at 7:01 am

    Why don’t you use a dataset as podiluska mentioned, and then access the DataSet.Tables property to gets your three table one by one.

    If the three table structure is difderent does not make sense to foece them into a table. For this the DataSet is the better way. It is kind of collection of your table.

    EDIT for the question about the DataTable[]:

    DataTable[] dtOutputs = Generix.getGraphData(type); 
    //dtReturn[0]
    DataTable dtOutput0 = dtOutputs[0];
    //dtReturn[1]
    DataTable dtOutput1 = dtOutputs[1];
    //dtReturn[2]
    DataTable dtOutput2 = dtOutputs[2];
    

    Or if you need not only reference those table, but copy them, you can use .Copy() like:

    //dtReturn[0]
    DataTable dtOutput1 = dtOutputs[1].Copy;
    

    I still think that the best way would be returning a DataSet by the query (it doesn’t make sense to make a DataTable query from that.)

    public static DataSet getGraphData(Int32 type)
    {
        SqlConnection oConn = null;
        DataSet dsReturn = null;
        try
        {
            getConnection(ref oConn, 1);
    
            using (SqlStoredProcedure sspObj = new SqlStoredProcedure("dbo.usp_getGraphData", oConn, CommandType.StoredProcedure))
            {
                sspObj.AddParameterWithValue("@Type", SqlDbType.Int, 0, ParameterDirection.Input, type);
                dsReturn = sspObj.ExecuteDataSet();
                //You don't need Dispose() - because the using will do that on sspObj
            }
    
            closeConnection(ref oConn);
        }
        catch (Exception xObj)
        {
            dsReturn = new DataSet("Empty");
        }
        return dsReturn ;
    }
    

    And calling the method like this:

     DataSet dsOutput = Generix.getGraphData(type);
    
        //Simply a reference or Copy() the DataSet's tables:
        DataTable dtOutput0 = dsOutput.Tables[0];
        DataTable dtOutput1 = dsOutput.Tables[1];
        DataTable dtOutput2 = dsOutput.Tables[2];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a stored procedure that returns a dynamic query, e,g if i pass
I have a stored procedure which returns multiple result sets similiar to the following:
I have a stored procedure that, depending on the input, returns multiple rows of
I have a very simple stored procedure which returns multiple record sets. All of
I have a stored procedure which returns sys_refcursor and I am trying to fetch
I have a stored procedure which returns a ref cursor as follows: CREATE OR
I have a stored procedure called WEB_SEL_SECURITY_QUESTIONS in my sql database which returns a
I have a stored procedure which executes another procedure inside it. The second one
I have a stored procedure which returns all the fields of a table plus
I have a datagridview and it is bound to a stored procedure which returns

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.