473,668 Members | 2,413 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cache.insert problem

Hi there

I am using the following to take an account number from a datagrid in to
another page and use it to load specific details according to the account
number:

Public Sub CustomerSearchG rid_ItemCommand (ByVal source As Object, ByVal e As
System.Web.UI.W ebControls.Data GridCommandEven tArgs) Handles
CustomerSearchG rid.ItemCommand
If e.Item.ItemInde x >= 0 Then

Dim Ownercell1 As TableCell = CType(e.Item.Co ntrols(1), TableCell)
Cache.Insert("S earchAccountNum ber", Ownercell1.Text & "%")
Server.Transfer ("/Application/CustomerBasicIn fo.aspx")
End If
End sub
*****

This works fine when the user clicks the grid the first time - but if the
BACK button is used in the browser and another entry in the datagrid
selected, the first selection remains in the cache and the first record keeps
coming back. If you hit refresh in the browser it intermittently works
correctly - but obviously this is not acceptable.

It would seem to me that the cache is not refreshing itself - I have tried
using cache.remove infront of the above but it makes no difference.... I feel
I am missing something obvious here.

If anyone knows - I would appreciate your input.

Thanks

Stuart
Nov 19 '05 #1
2 1694
Stuart...the cache isn't the right object for the job. Cache is shared
amongst all users..so you'll run into all types of
race-conditions...Co nsider placing things in the HttpContext.Ite m
collection...yo u can read more on this at:
http://odetocode.com/Articles/111.aspx

and on storage objects in general at:
http://www.openmymind.net/DataStorage/index.html
I think this will be the irst step in solving your problem.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Stuart" <St****@discuss ions.microsoft. com> wrote in message
news:6F******** *************** ***********@mic rosoft.com...
Hi there

I am using the following to take an account number from a datagrid in to
another page and use it to load specific details according to the account
number:

Public Sub CustomerSearchG rid_ItemCommand (ByVal source As Object, ByVal e As System.Web.UI.W ebControls.Data GridCommandEven tArgs) Handles
CustomerSearchG rid.ItemCommand
If e.Item.ItemInde x >= 0 Then

Dim Ownercell1 As TableCell = CType(e.Item.Co ntrols(1), TableCell) Cache.Insert("S earchAccountNum ber", Ownercell1.Text & "%")
Server.Transfer ("/Application/CustomerBasicIn fo.aspx")
End If
End sub
*****

This works fine when the user clicks the grid the first time - but if the
BACK button is used in the browser and another entry in the datagrid
selected, the first selection remains in the cache and the first record keeps coming back. If you hit refresh in the browser it intermittently works
correctly - but obviously this is not acceptable.

It would seem to me that the cache is not refreshing itself - I have tried
using cache.remove infront of the above but it makes no difference.... I feel I am missing something obvious here.

If anyone knows - I would appreciate your input.

Thanks

Stuart

Nov 19 '05 #2
Thanks Karl

I tried that, but I think I need to store the variable for more than one
hit...

Therefore I have tried using Session.Add to store the variable instead -
again this works fine for the first attempt, but I don't seem to be able to
overwrite the session variable in the same way.

If on the first click of the datagrid I use Session.Add("Na me", value) the
Server.Transfer takes me to the correct page and retireves data correctly
according to the variable stored on the previous page - all good...

I then click BACK in the browser which displays my datagrid again - I choose
another record in the datagrid and use, obviously, the same Session.Add code
as the first time - Is something going wrong here ? Am I using Session.Add in
the correct way - is it supposed to overwrite the content of the session
variable when it is not null ? I have an inkling that this is something to do
with the fact that I click BACK ?

I Am Confused.... any more ideas would be great !

Thanks again

"Karl Seguin" wrote:
Stuart...the cache isn't the right object for the job. Cache is shared
amongst all users..so you'll run into all types of
race-conditions...Co nsider placing things in the HttpContext.Ite m
collection...yo u can read more on this at:
http://odetocode.com/Articles/111.aspx

and on storage objects in general at:
http://www.openmymind.net/DataStorage/index.html
I think this will be the irst step in solving your problem.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Stuart" <St****@discuss ions.microsoft. com> wrote in message
news:6F******** *************** ***********@mic rosoft.com...
Hi there

I am using the following to take an account number from a datagrid in to
another page and use it to load specific details according to the account
number:

Public Sub CustomerSearchG rid_ItemCommand (ByVal source As Object, ByVal e

As
System.Web.UI.W ebControls.Data GridCommandEven tArgs) Handles
CustomerSearchG rid.ItemCommand
If e.Item.ItemInde x >= 0 Then

Dim Ownercell1 As TableCell = CType(e.Item.Co ntrols(1),

TableCell)
Cache.Insert("S earchAccountNum ber", Ownercell1.Text & "%")
Server.Transfer ("/Application/CustomerBasicIn fo.aspx")
End If
End sub
*****

This works fine when the user clicks the grid the first time - but if the
BACK button is used in the browser and another entry in the datagrid
selected, the first selection remains in the cache and the first record

keeps
coming back. If you hit refresh in the browser it intermittently works
correctly - but obviously this is not acceptable.

It would seem to me that the cache is not refreshing itself - I have tried
using cache.remove infront of the above but it makes no difference.... I

feel
I am missing something obvious here.

If anyone knows - I would appreciate your input.

Thanks

Stuart


Nov 19 '05 #3

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

Similar topics

3
4308
by: Dave | last post by:
I am currently having a problem with retaining the cache in my asp.net application. I am trying to insert a small DataView into cache, then recall it on various pages throughout the site. When on any page other than the page that inserted the cache, the DataView is null (not the cache object, but the DataView itself). I'm curious as to if my code is wrong, or if the DataView wasn't meant to be placed into cache. // Code for insert...
1
3175
by: Glenn | last post by:
Hi, I have a config XML file that I am using from the application cache. I have configured the entry with a remove callback to re-populate cache automatically when the XML file changes. All is well until the XML file is changed. The cached item is being removed as I would expect, but the remove callback is not firing at all, hence a NullReferenceException is being raised when I try to access the cache object. Please see code snippet...
4
5356
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 a lock using code like below (just typed this in); Cache thisCache = HttpContext.Current.Cache lock(thisCache)
13
1780
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 null, DateTime.Now.AddSeconds(600),
2
1581
by: Andrew | last post by:
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 == null) { Cache.Insert("testQuestion"+ i, ds.Tables); }
5
2110
by: Stan SR | last post by:
Hi, Some newbie questions.. :-) First, what is the namespace to use for the Cache class ? When I use this bit of code I get an error if (Cache==null) Cache.Insert("myUserList",userlist); I don't know which namespace to use.
1
1395
by: =?Utf-8?B?ZGF2ZQ==?= | last post by:
I have an asp.net project with a business layer (project) that has a class called references. It loads up a data set and stores in cache with the following code. _cached = CType(HttpContext.Current.Cache("cached"), String) If HttpContext.Current.Cache("cached") Is Nothing Or _cached <> "loaded" Then MyBase.CreateCommand("SA_GetReferences", _connectionString) _dsReferences = MyBase.ExecDataSet...
0
1610
by: shaiknayeemuddin | last post by:
Hi, I am facing one problem, We have data in Oracle Table and fetching that data from Cache Database using link server concept. I am able to fetch data through Cache query in Cache Studio from Oracle, like Cache Query: SELECT * FROM DATAMASK.TBL_MASKED_STG;
0
6255
by: pmouse | last post by:
Hi Guys, I've written a templated lru cache based on the SGI version of STL. To use the class, simply write: lru_cache<key_type, data_type, cache_length, custom_containercache; cache.insert( key, value ); cache = value2; data_type* pvalue3 = cache.get(key3); if ( pvalue3 == NULL ) {} // cache missing else
2
2852
by: =?Utf-8?B?Y2F0?= | last post by:
We recently moved an older ASP.NET 1.1 code base on to ASP.NET 2.0, .NET 3.0 and Windows 2003 Server SP2. We started experiencing the following issue with the web cache (the code is straightforward and worked flawlessy before the upgrade): Dim o As Object = Cache.Get(key) If o Is Nothing Then Cache.Insert(key, GetTheData()) o = Cache.Get(key) End If
0
8382
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8893
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8802
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6209
isladogs
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5682
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4206
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4384
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2792
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2028
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.