Click here to Skip to main content
14,544,380 members


AnswerRe: BroadcastMessage Pin
MaulikDusara19-Sep-11 2:14
MemberMaulikDusara19-Sep-11 2:14 2010 web.config Pin
Member 821751716-Sep-11 6:59
MemberMember 821751716-Sep-11 6:59 
Questionhow to send mail without internet connection Pin
sathyan_829416-Sep-11 6:43
Membersathyan_829416-Sep-11 6:43 
AnswerRe: how to send mail without internet connection Pin
Richard MacCutchan17-Sep-11 1:20
mveRichard MacCutchan17-Sep-11 1:20 
GeneralRe: how to send mail without internet connection Pin
GenJerDan17-Sep-11 1:51
MemberGenJerDan17-Sep-11 1:51 
GeneralRe: how to send mail without internet connection Pin
Richard MacCutchan17-Sep-11 2:46
mveRichard MacCutchan17-Sep-11 2:46 
QuestionMVC3 DropDownList Question Pin
eddieangel16-Sep-11 6:41
Membereddieangel16-Sep-11 6:41 
QuestionNeed lowdown on my custom CacheDependency implementation [modified] Pin
Jaime Premy15-Sep-11 16:46
professionalJaime Premy15-Sep-11 16:46 
Sigh | :sigh: I've been using Data CacheDependency for a while now for my XML File based data.

But then I suddenly had the need to use a data cache for my SQL Server based Products table and started looking around for some help.

Then I found this:

After taking a look at this tutorial, I said "Wow, there goes my sunday afternoon!".

But being lazy as I am, I started wondering if there wouldn't be an easier way for achieving what I wanted, and this is what I came up with.

1. I created a Table named TableChanged with 2 columns:

- TableName varchar(20)

- Changed bit

The idea is to track changes made to other tables; for the time being there is only 1 row in it:

TableName Changed
Products True

2. I created a trigger in the Products table:


ON dbo.Products



Update  TableChanged Set Changed = 1 WHERE TableName='Products' 

So everytime something changes in Products, the value of Changed becomes True, in TableChanged.

I created the same trigger in table Categories, since it's related to Products.

3. In PageLoad I did:

If Not IsPostBack Then            
Dim dv As DataView
            Dim changed As Boolean = Global.CheckChanged("Products")
            If changed Then
                dv = LoadDV()
                dv = Cache("cachedDV")
                If dv Is Nothing Then 'in case application restarts, changed will be false and dv null
                    dv = Cache("cachedDV")
                End If
            End If

Protected Function LoadDV() As DataView
        Dim dt As DataTable = Product.GetDiscounted
        Dim dv As DataView = New DataView(dt)
        Cache("cachedDV") = dv
        Return dv
    End Function

Global and Product are classes in my BOL which handles the dataconnection thru my DAL. The sprocs used for CheckChanged and UpdateChanged are the following:

ALTER PROCEDURE dbo.TableChangedCheck
	@sTable varchar(20)
	Select Changed From TableChanged WHERE TableName=@sTable

ALTER PROCEDURE dbo.TableChangedUpdate
	@sTable varchar(20)
	UPDATE TableChanged SET Changed = 0 WHERE TableName=@sTable

So, on Pageload, if changed = true the dataview gets populated from the db and is added to the cache, while the row "Products" in TableChanged gets flagged as False.
On subsequent Pageloads, changed = false, so the dv gets populated from the cached dv;
And this goes on until either the Products or Category table get altered or the application restarts.
Very well then, this seems to work. My question is now why would the people at MS dream up
the SqlDependency Class if the same result can be achieved in this (apparently) much simpler manner?
What are the hidden pitfalls, drawbacks, disadvantages, if any, of my custom implementation.
I was hoping someone more experienced on the subject could reassure me to stay with it.
In this case it might help out others too, looking for the same thing.

Thank u for your attention
Jaime Premy

modified on Friday, September 16, 2011 8:43 AM

AnswerRe: Need lowdown on my custom CacheDependency implementation Pin
Parwej Ahamad15-Sep-11 19:22
professionalParwej Ahamad15-Sep-11 19:22 
QuestionNeed help with Multi Select Drop down display Pin
Parul Jee15-Sep-11 10:46
MemberParul Jee15-Sep-11 10:46 
AnswerRe: Need help with Multi Select Drop down display Pin
MaulikDusara19-Sep-11 2:17
MemberMaulikDusara19-Sep-11 2:17 buttons Pin
jassiedog15-Sep-11 10:08
Memberjassiedog15-Sep-11 10:08 
AnswerRe: buttons Pin
Parwej Ahamad15-Sep-11 19:27
professionalParwej Ahamad15-Sep-11 19:27 
QuestionAccess physical file in AS 400 from stored procedure Pin
Member 322226415-Sep-11 6:11
MemberMember 322226415-Sep-11 6:11 
Questionweb forms 2010 Pin
classy_dog15-Sep-11 5:21
Memberclassy_dog15-Sep-11 5:21 
Questionvs 2008 Pin
classy_dog15-Sep-11 5:20
Memberclassy_dog15-Sep-11 5:20 
QuestionModalPopUpExtender Not showing on IE9 Pin
Vasanthakumar14-Sep-11 19:44
MemberVasanthakumar14-Sep-11 19:44 
AnswerRe: ModalPopUpExtender Not showing on IE9 Pin
Satish_S15-Sep-11 20:03
MemberSatish_S15-Sep-11 20:03 
QuestionControl is null while using generic method [modified] Pin
kstxx14-Sep-11 7:01
Memberkstxx14-Sep-11 7:01 
GeneralImport Google Mail Contacts in Your ASP.NET Web Application Pin
AditSheth13-Sep-11 18:49
MemberAditSheth13-Sep-11 18:49 
QuestionEnvironment.CurrentDirectory and Multiple Page Requests Pin
Nathan Stiles13-Sep-11 17:48
MemberNathan Stiles13-Sep-11 17:48 
Questionjavascript alert Pin
Dushan12313-Sep-11 15:20
MemberDushan12313-Sep-11 15:20 
AnswerRe: javascript alert Pin
Shah Rizal13-Sep-11 22:14
MemberShah Rizal13-Sep-11 22:14 
QuestionMethod not firing Pin
Rick van Woudenberg13-Sep-11 12:56
MemberRick van Woudenberg13-Sep-11 12:56 
AnswerRe: Method not firing Pin
Pravin Patil, Mumbai13-Sep-11 19:50
MemberPravin Patil, Mumbai13-Sep-11 19:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.