HighTechTalks DotNet Forums  

.NET 2.0, SqlCacheDependancy not expiring the cache

ASP.net Caching microsoft.public.dotnet.framework.aspnet.caching


Discuss .NET 2.0, SqlCacheDependancy not expiring the cache in the ASP.net Caching forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Adam Tibi
 
Posts: n/a

Default .NET 2.0, SqlCacheDependancy not expiring the cache - 02-20-2006 , 06:30 AM






Hello,
SqlCacheDependency sqlCacheDependency = new SqlCacheDependency("MyDBName",
"dbo.MyTableName");
HttpContext.Current.Cache.Insert("key", "value", sqlCacheDependency);

This code works as expected and expires the "key" when the table
dbo.MyTableName has any record changed.

However, in the same position, if you replace this code with this one:

SqlCommand command = new SqlCommand("SELECT SomeField FROM dbo.MyTableName",
new
SqlConnection(ConfigurationManager.ConnectionStrin gs["Default"].ConnectionString));
SqlCacheDependency sqlCacheDependency = new SqlCacheDependency(command);
HttpContext.Current.Cache.Insert("key", "value", sqlCacheDependency);

It doesn't work if you change any value within the "SomeField", I even tried
setting a wrong select statment to check if it is being executed but nothing
happened, also tried to replace the connection string with one that doesn't
point to a real database but nothing happened as well (do I need to open the
connection myself?)!

I assume the database is well configured and I didn't miss any configuration
because the first code worked fine for me, does any one have a clue what I
might be missing in the second code?

Thank you in advance,
Adam





Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.