im having my first play about with caching a dataset but seem to be having some problems in doing so!!
basically i have a dataset which i add to the cache as follows
Cache.Insert("myDS", dsResults, Nothing, DateTime.Now.AddMinutes(5), TimeSpan.Zero)
i then have a select button which i click so that the page is reloaded. so that i can only get the dataset from the cache
but when i do the following
dsResults = New DataSet
dsResults = Cache.Item("myDS")
i get Referenced object has a value of 'Nothing'.
what am i doing wrong??
Cheers,
Craig 5 1562
To store the dataset:
Cache.Insert("myDS", dsResults)
To retrieve the dataset:
dim ds as DataSet 'Note the omission of the "New" keyword
ds = Cache.Item("myDS")
"Craig G" <craig.gamble@y_arrasoftware.com> wrote in message news:en**************@TK2MSFTNGP12.phx.gbl...
im having my first play about with caching a dataset but seem to be having some problems in doing so!!
basically i have a dataset which i add to the cache as follows
Cache.Insert("myDS", dsResults, Nothing, DateTime.Now.AddMinutes(5), TimeSpan.Zero)
i then have a select button which i click so that the page is reloaded. so that i can only get the dataset from the cache
but when i do the following
dsResults = New DataSet
dsResults = Cache.Item("myDS")
i get Referenced object has a value of 'Nothing'.
what am i doing wrong??
Cheers,
Craig
Cache.Insert("myDS", dsResults, Nothing,
System.Web.Caching.Cache.NoAbsoluteExpiration, TimeSpan.FromSeconds(300))
Craig, the last argument is how long to stay in cache, the one above I keep
it there for 5 minutes. Try that instead of Zero
Al
"Craig G" wrote: im having my first play about with caching a dataset but seem to be having some problems in doing so!!
basically i have a dataset which i add to the cache as follows
Cache.Insert("myDS", dsResults, Nothing, DateTime.Now.AddMinutes(5), TimeSpan.Zero) i then have a select button which i click so that the page is reloaded. so that i can only get the dataset from the cache
but when i do the following dsResults = New DataSet
dsResults = Cache.Item("myDS") i get Referenced object has a value of 'Nothing'.
what am i doing wrong?? Cheers, Craig
nope still no joy , used both your ideas
but as soon as i click the button myDS is lost!!
ive checked before the button click and it does create it and there is data
in it
here is my button click code
Private Sub btnSearch_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnSearch.Click
Dim strCode As String = txtCode.Text
Dim strDescription As String = txtDescription.Text
Dim strFilter As String
Dim drFilteredRows As DataRow()
Dim dtDataTable As New DataTable
Dim dsResults As DataSet
dsResults = CType(Cache.Item("myDS"), DataSet)
strFilter = "Code='" & strCode & "' AND Description='" & strDescription &
"'"
drFilteredRows = dsResults.Tables(0).Select(strFilter)
"Albert Pascual" <Al***********@discussions.microsoft.com> wrote in message
news:3E**********************************@microsof t.com... Cache.Insert("myDS", dsResults, Nothing, System.Web.Caching.Cache.NoAbsoluteExpiration, TimeSpan.FromSeconds(300))
Craig, the last argument is how long to stay in cache, the one above I
keep it there for 5 minutes. Try that instead of Zero
Al
"Craig G" wrote:
im having my first play about with caching a dataset but seem to be
having some problems in doing so!! basically i have a dataset which i add to the cache as follows
Cache.Insert("myDS", dsResults, Nothing, DateTime.Now.AddMinutes(5),
TimeSpan.Zero)
i then have a select button which i click so that the page is reloaded.
so that i can only get the dataset from the cache but when i do the following dsResults = New DataSet
dsResults = Cache.Item("myDS") i get Referenced object has a value of 'Nothing'.
what am i doing wrong?? Cheers, Craig
Craig, the code I gave you is the correct code (note that you don't create
a new dataset when retrieving), but you say it doesn't work when you hit the
Back button. Well, hitting the Back button does not cause the page code to
be executed, it only brings up what the browser has stored in its LOCAL
cache from the last time this page was called. Hit the REFRESH button to
cause the page code to be run.
"Craig G" <craig.gamble@y_arrasoftware.com> wrote in message
news:ex**************@TK2MSFTNGP09.phx.gbl... nope still no joy , used both your ideas
but as soon as i click the button myDS is lost!!
ive checked before the button click and it does create it and there is data in it here is my button click code
Private Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click
Dim strCode As String = txtCode.Text
Dim strDescription As String = txtDescription.Text
Dim strFilter As String
Dim drFilteredRows As DataRow()
Dim dtDataTable As New DataTable
Dim dsResults As DataSet dsResults = CType(Cache.Item("myDS"), DataSet)
strFilter = "Code='" & strCode & "' AND Description='" & strDescription & "'"
drFilteredRows = dsResults.Tables(0).Select(strFilter)
"Albert Pascual" <Al***********@discussions.microsoft.com> wrote in message news:3E**********************************@microsof t.com... Cache.Insert("myDS", dsResults, Nothing, System.Web.Caching.Cache.NoAbsoluteExpiration, TimeSpan.FromSeconds(300))
Craig, the last argument is how long to stay in cache, the one above I
keep it there for 5 minutes. Try that instead of Zero
Al
"Craig G" wrote:
> im having my first play about with caching a dataset but seem to be having some problems in doing so!! > > basically i have a dataset which i add to the cache as follows > > Cache.Insert("myDS", dsResults, Nothing, DateTime.Now.AddMinutes(5), TimeSpan.Zero) > > > > i then have a select button which i click so that the page is reloaded. so that i can only get the dataset from the cache > > but when i do the following > dsResults = New DataSet > > dsResults = Cache.Item("myDS") > > > > i get Referenced object has a value of 'Nothing'. > > what am i doing wrong?? > Cheers, > Craig > > >
"Craig G" <craig.gamble@y_arrasoftware.com> wrote in message
news:en**************@TK2MSFTNGP12.phx.gbl...
im having my first play about with caching a dataset but seem to be having
some problems in doing so!!
basically i have a dataset which i add to the cache as follows
Cache.Insert("myDS", dsResults, Nothing, DateTime.Now.AddMinutes(5),
TimeSpan.Zero)
i then have a select button which i click so that the page is reloaded. so
that i can only get the dataset from the cache
but when i do the following
dsResults = New DataSet
dsResults = Cache.Item("myDS")
i get Referenced object has a value of 'Nothing'.
what am i doing wrong??
Cheers,
Craig
This function is a bit more generic but it may help you.
Public Shared Function mgGetMetaTagsXML() as datatable
dim dt as datatable
'HttpContext.Current.cache.remove("MetaData") 'for testing
dt = CType(HttpContext.Current.Cache("MetaData"), DataTable)
if dt is nothing then
Dim ds AS DataSet = New Dataset
Dim strPathFull as string = strPath &
ConfigurationSettings.AppSettings("dbroot") & "tblMetaTags.xml"
ds.ReadXml(strPathFull, XmlReadMode.InferSchema)
dt =ds.tables(0)
ds = nothing
HttpContext.Current.Cache.Insert ("MetaData",dt,New
CacheDependency(strPathFull),DateTime.MaxValue, TimeSpan.FromMinutes(60))
end if
return dt
End Function
Mike This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: olle |
last post by:
Hi folks.
I learning asp.net and compare it with traditional asp and
Access-developing.
The issue is this one:
1/I have this Ms Acceess adp-project application that works fine on my
Ms Sql...
|
by: moko |
last post by:
I want to know whether 'dataset caching' is at the client end , or the
server ? Similarly is an aspx page caching at the server or client ?
Are there any 'gotchas' with caching ?
|
by: Gavin Pollock |
last post by:
Is anyone using Caching (HttpRuntime.Cache) in Whidbey? Not sure if there's
another newsgroup for this though since it's still beta....
I'm having issues running a system built on 1.1 in a 2.0...
|
by: BillGatesFan |
last post by:
I'm trying to understand ASP.NET caching. I set the Page Output
directive to VaryByParams= None and the duration = 60.
Now whenever users hit my web app they can see each others data. Is
there...
|
by: Rick Hein |
last post by:
I've got a problem with an app I've been working on, the Caching object and
events not firing correctly. In a nutshell: When I'm debugging, and I set a
breakpoint in the removed item call back, the...
|
by: Ben Fidge |
last post by:
What are best practices for page output caching on pages that are dynamically
generated from database tables.
Our site has left-hand navigation that is comprised of dynamically generated
menus...
|
by: RickG |
last post by:
Can anybody clarify this please.
Is there any problem in a web app of saving an object in a public variable
as opposed to saving it in the cache?
In my case, I have an object containing a hash...
|
by: Fred Nelson |
last post by:
Hi:
I have written several web applications that obtain their connection
strings from the web.config file. This is very easy to use and it makes
it easy to move an app from development into...
|
by: Fred Nelson |
last post by:
Hi:
This is probably a newby question however I can't figure it out!
I'm trying to use application data caching in a web application. I have
read an article on 4 guys from rolla that shows...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
|
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,...
|
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |