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 6071943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:06:18+00:00 2026-05-23T10:06:18+00:00

I have a stored procedure as pr___GetArchiveData Select * from TABLE1 SELECT * FROM

  • 0

I have a stored procedure as

pr___GetArchiveData

Select * from TABLE1

SELECT * FROM TABLE2

SELECT * FROM TABLE 3

I want to get this result set into a dataset. Or access the values of three select queries!!
I have a DBML file in which when i drag and drop the stored procedure generates a code as follows:-

global::System.Data.Linq.Mapping.FunctionAttribute(Name="dbo.pr___GetArchiveData")]
    public ISingleResult<pr___GetArchiveDataResult> pr___GetArchiveData([global::System.Data.Linq.Mapping.ParameterAttribute(DbType="UniqueIdentifier")] System.Nullable<System.Guid> projectID)
    {
        IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), projectID);
        return ((ISingleResult<pr__Project_pr___GetArchiveData>)(result.ReturnValue));
    }

In the code MVC3 Architecture + LINQ i have written a code to get the result set as follows :-

using (HBDataContext hb = new HBDataContext())
                {
                    System.Data.DataSet ds = new System.Data.DataSet();

                    String connString = connString;

                    var conn = new System.Data.SqlClient.SqlConnection(connString);
                    var cmd = conn.CreateCommand();

                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    cmd.CommandText = "pr__GetArchiveData";
                    cmd.Connection.Open();

                    var mReader = cmd.ExecuteReader(System.Data.CommandBehavior.SequentialAccess);
                    //var reader = cmd.ExecuteReader();

                    //using (System.Data.SqlClient.SqlDataReader mReader = cmd.ExecuteReader())
                    //{
                    //  while (mReader.Read())
                    //{
                    // mReader.Read();

                    var tbl1 = hb.Translate<tbl1 >(mReader).ToList();

                  //  mReader = cmd.ExecuteReader();

                    mReader.NextResult();
                    var tbl2 = hb.Translate<tbl2 >(mReader).ToList();

                    mReader.NextResult();
                    var tbl3 = hb.Translate<tbl3>(mReader).ToList();

                  
                    // }
                    // }
                }

But while running it throws error as –

"Invalid attempt to call NextResult when reader is closed."

I am not sure where i am wrong!!

I have tried using it as while

(mReader.Read())

Kindly suggest!!!!

  • 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-05-23T10:06:18+00:00Added an answer on May 23, 2026 at 10:06 am
    1. In .dbml file for the stored procedure the code will be like

      [global::System.Data.Linq.Mapping.FunctionAttribute(Name="dbo.pr__Home_GetArchiveData")]
      public ISingleResult<pr__Home_GetArchiveData> pr__Home_GetArchiveData([global::System.Data.Linq.Mapping.ParameterAttribute(Name="AlbumID", DbType="UniqueIdentifier")] System.Nullable<System.Guid> albumID)
      {
      IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), albumID);
      return ((ISingleResult<pr__Album_GetAlbumsFilesResult>)(result.ReturnValue));
      }

    2. Replace it with IMultipleResult as below `

      [global::System.Data.Linq.Mapping.FunctionAttribute(Name = “dbo.pr__Home_GetArchiveData”)]
      [ResultType(typeof(tbl1))]
      [ResultType(typeof(tbl2))]
      [ResultType(typeof(tbl3))]
      [ResultType(typeof(tbl4))]
      public IMultipleResults pr__Home_GetArchiveData([global::System.Data.Linq.Mapping.ParameterAttribute(Name = “HOMEID”, DbType = “UniqueIdentifier”)] System.Nullable hOMEID)
      {
      IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), hOMEID);
      return ((IMultipleResults)result.ReturnValue);
      }

    in the code .

     using (HBDataContext hb = new HBDataContext())
                    {
                        using (System.Data.Linq.IMultipleResults _results = hb.pr__Home_GetArchiveData(model.HomeID))
                        {
                            List<tbl1> _tbl1= _results.GetResult<tbl1>().ToList();
                            List<tbl2> _tbl2= _results.GetResult<tbl2>().ToList();
                            List<tbl3> _tbl3= _results.GetResult<tbl3>().ToList();
                            List<tbl4> _tbl4= _results.GetResult<tbl4>().ToList();}}
    

    You will get the values of the Select queries from theStoredProcedure …

    • 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 uses sp_executesql to generate a result set, the
I have a stored procedure that returns around 1000 rows. I want to SELECT
I have stored procedure which I will execute its result and pass it into
I have a stored procedure in Oracle that returns result set(s) via OUT parameter(s)
I have stored procedure: ALTER PROCEDURE [dbo].[k_ShoppingCart_DELETE] @cartGUID nvarchar AS DELETE FROM [dbo].[k_ShoppingCart] WHERE
I have a stored procedure that consists of a single select query used to
I have a Stored Procedure that rolls-back a series of operations. I want to
I have a Stored procedure which schedules a job. This Job takes a lot
I have stored-procedure in Oracle database like this: create or replace PROCEDURE EDYTUJ_PRACOWNIKA (PR_IMIE
I have stored procedure (unorganized - not properly outlined) I want automatic outlining in

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.