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
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

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Question has a verified solution.

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

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…
Suggested Courses
Course of the Month8 days, 16 hours left to enroll

621 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