473,387 Members | 1,295 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

trying to cache a dataSet

I hope this doesn't sound too silly. I am trying to cache a datatSet. I have
written the code below.

I insert into the cache:
Eg. i = 1.

if (Cache["testQuestion"+ i] == null)
{
Cache.Insert("testQuestion"+ i, ds.Tables[i]);
}

retrieve from the cache:

DataSet ds2 = (DataSet)Cache["testQuestion"+ (int)ViewState["QnNo"]];
if (ds2 != null)
{
ds2 = (DataSet)Cache["testQuestion"+ (int)ViewState["QnNo"]];
MyRepeater.DataSource = ds.Tables[(int)ViewState["QnNo"]];
MyRepeater.DataBind();
}

Is there a problem there ?
TIA.
Nov 19 '05 #1
2 1561
Hi,
I agree to what Grant is saying. Please try this out.

if (Cache["testQuestion"+ i] == null)
{
Cache.Insert("testQuestion"+ i, ds.Tables[i]);
}

retrieve from the cache:

DataTable dt2 = (DataTable)Cache["testQuestion"+ (int)ViewState["QnNo"]];
if (dt2 != null)
{
dt2 = (DataTable)Cache["testQuestion"+ (int)ViewState["QnNo"]];
MyRepeater.DataSource = dt2;
MyRepeater.DataBind();
}

All i have done here is modified your original code little bit. And Please
be assured that it wont bother your logic of accessing exactly that number of
table in the original dataset that you have implemented by using "i". :)

Hoping a thanks as it is going to work out perfectly.

"Andrew" wrote:
I hope this doesn't sound too silly. I am trying to cache a datatSet. I have
written the code below.

I insert into the cache:
Eg. i = 1.

if (Cache["testQuestion"+ i] == null)
{
Cache.Insert("testQuestion"+ i, ds.Tables[i]);
}

retrieve from the cache:

DataSet ds2 = (DataSet)Cache["testQuestion"+ (int)ViewState["QnNo"]];
if (ds2 != null)
{
ds2 = (DataSet)Cache["testQuestion"+ (int)ViewState["QnNo"]];
MyRepeater.DataSource = ds.Tables[(int)ViewState["QnNo"]];
MyRepeater.DataBind();
}

Is there a problem there ?
TIA.

Nov 19 '05 #2
Thanks.

"Andrew" wrote:
I hope this doesn't sound too silly. I am trying to cache a datatSet. I have
written the code below.

I insert into the cache:
Eg. i = 1.

if (Cache["testQuestion"+ i] == null)
{
Cache.Insert("testQuestion"+ i, ds.Tables[i]);
}

retrieve from the cache:

DataSet ds2 = (DataSet)Cache["testQuestion"+ (int)ViewState["QnNo"]];
if (ds2 != null)
{
ds2 = (DataSet)Cache["testQuestion"+ (int)ViewState["QnNo"]];
MyRepeater.DataSource = ds.Tables[(int)ViewState["QnNo"]];
MyRepeater.DataBind();
}

Is there a problem there ?
TIA.

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: martin | last post by:
Hi, I am storing a dataset in cache, which is happening fine. I can easily retrive it at postback from the cache, cast it to a dataset and reuse it. However I have specified that the cache...
5
by: sklett | last post by:
Hi- I am having a hard time decided where I should be implementing my Cache code. I store most of the DataSet's that I need in the Cache. I was doing it in the bind method of my pages, but...
2
by: stefano mostarda | last post by:
Hi there, In my application I need a dataset containing tables often used in pages. They must be always available so I though Application would likely be the best place to store the dataset. But...
4
by: Mat | last post by:
Hi, I've stumbled onto a problem when using the caching object in ASP.Net. I'm placing a static dataset to the cache as the data only changes once a day. Whilst writing to the cache I'm using...
13
by: Fernando Chilvarguer | last post by:
Hi, I'm retriving data from a database and storing it on the Cache Object using the following code: HttpContext.Current.Cache.Insert( cacheItemKey, contentDS, //THE DATASET WITH MY DATA...
5
by: Darrel | last post by:
I thought this warranted a new thread. Yesterday I asked about access relatively static content...is it better to read from the DB, or just grab a text file. It was suggested that I use the DB...
3
by: Jon | last post by:
I have a couple of tables I want to load into a dataset and keep around pretty much forever, although they will need to be refreshed every so often. I can either put the dataset into an...
5
by: Andrew | last post by:
I insert into the cache: if (Cache == null) { Cache.Insert("testQuestion"+ i, ds.Tables); }
3
by: mrutyunjaya | last post by:
if (Cache==null) { SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings.ConnectionString); SqlDataAdapter mydataadapter = new...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.