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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:42:33+00:00 2026-05-31T01:42:33+00:00

I have a stored procedure that returns a list. Now I’m trying to write

  • 0

I have a stored procedure that returns a list. Now I’m trying to write a function that will pass the stored procedure that correct parameter and then return the list so that it can be used on asp web page. I’m completely lost.

I’ve tried this so far to no avail

public static List<RetrieveActiveMuseumByMuseumID_Result> GetActiveMuseum()
{
     using (MuseumDB db = new MuseumDB(ConfigurationManager.ConnectionStrings["MuseumDB"].ConnectionString))
     {
          List<RetrieveActiveMuseumByMuseumID_Result> listOrdered = new List<RetrieveActiveRigsWithEquipmentByOffice_Result>();
     }
  return listOrdered;
 }

But that doesn’t do anything and it doesn’t pass the parameter of the SP which is @MuseumID

Help please I don’t know where to go from here.

  • 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-31T01:42:34+00:00Added an answer on May 31, 2026 at 1:42 am

    For Asp.net data sources: List == bad, Enumerable == good. Both can be used as a data source, but enumerables tend to perform better, especially for asp.net where memory use is so important. Lists force you to have the entire result set in memory. Play your cards right with an enumerable, and you may only need one record in memory at a time.

    public static IEnumerable<RetrieveActiveMuseumByMuseumID_Result> GetActiveMuseum()
    {
         using (var cn = new SqlConnection(ConfigurationManager.ConnectionStrings["MuseumDB"].ConnectionString))
         using (var cmd = new SqlCommand("StoredProcedureName", cn)
         {
              cmd.CommandType = CommandTypes.StoredProcedure;
              //you need to supply some of the information for this line: you didn't include it in your question
              cmd.Parameters.Add("@ParameterName", SqlDbTypes.???).Value = ParameterValue;
    
              cn.Open();
              using (var rdr = cmd.ExecuteReader())
              {
                   while (rdr.Read())
                   {  //you'll need to implement the static create method I used here
                       yield return new RetrieveActiveMuseumByMuseumID_Result.Create(rdr);
                   }
              }
         }
     }
    

    To make this work, your RetrieveActiveMuseumByMuseumID_Result type needs a static Create() method that accepts an IDataRecord and return a new RetrieveActiveMuseumByMuseumID_Result object (this follows the Factory pattern).

    I tend to abstract this pattern away to a “mini-ORM”, using a generic method that looks like this:

    public static IEnumerable<IDataRecord> GetData(string command, Action<SqlParameterCollection> addParameters)
    {
        using (var cn = new SqlConnection( /* generic code for connection string here */ ));
        using (var cmd = new SqlCommand(command, cn))
        {
            addParameters(cmd.Parameters);
    
            cn.Open();
            using (var rdr = cmd.ExecuteReader())
            {
                while (rdr.Read())
                {
                    yield return rdr;
                }
            }
        }
    }
    

    And then I would call that for your query like this:

    public static IEnumerable<RetrieveActiveMuseumByMuseumID_Result> GetActiveMuseum()
    { 
         return GetData("exec StoredProcedureName @ParameterName", p => 
              {
                 p.Add("@ParameterName", SqlDbTypes.???).Value = ParameterValue;
              }).Select(r => RetrieveActiveMuseumByMuseumID_Result.Create(r));
    }
    
    • 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 list of projectIDs at the moment.
I have a stored procedure in a SQL Server database that returns a list
I currently have a stored procedure that returns a list of account numbers and
I have a special stored procedure that returns a List of Distributors from my
I have a strange, sporadic issue. I have stored procedure that returns back 5
I have a stored procedure that returns multiple tables. How can I execute and
I have a stored procedure that returns values from a temp table. In my
I have a stored procedure that returns two int Values. The first can not
I have a stored procedure that returns a result with 250!!! columns. But I
Say I have a stored procedure that returns data from a SELECT query. I

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.