ASP.Net / C# - How do you cache a DataReader ?

Posted on 2005-03-24
Medium Priority
Last Modified: 2010-08-05
I'm selecting thousands of records using a data reader to populate a grid. How do I cache the data reader so I can just rebind after postbacks, without having to make a db call? Thanks!

      string SQL = "Select * from prospect order by prolast";
      OleDbCommand cmd = new OleDbCommand(SQL,oledbconn);
                cmd.CommandType = CommandType.Text;
      this.Grid.DataSource = cmd.ExecuteReader();

 Cache["dr"] = cmd.ExecuteReader() ????????  this will call read ! ,,,then  how do I cast it back to the grids.datasource ?

thanks again
Question by:JElster
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment

Accepted Solution

sudheeshthegreat earned 300 total points
ID: 13625342
guess you have posted this in the wrong channel.
To answer you question, you shouldn't cache a DataReader. You can create a DataSet (which is a disconnected object) instead and then cache it.

have a look at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/CachingArchch4.asp

Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question