473,408 Members | 2,405 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,408 software developers and data experts.

ASP.NET caching with SQL Server doesn't work. Help needed.

Hello! I'm trying to get caching work with ASP.NET 2.0 and SQL Server
Express Edition 2005, but I have a problem and I can't figure out what I'm
still doing wrong.

I have enabled the database for cache notification by running the
aspnet_regsql tool on the command line:
aspnet_regsql -S server -E -d database -et

Then I have run the aspnet_regsql tool to enable each table in the database
for cache notification:
aspnet_regsql -S server -E -d database -et -t tablename

I have added the necessary parts into web.config file, so that it is
like this:

<connectionStrings>
<add name="ConnectionString1" connectionString="Data
Source=servername;Database=databasename;Integrated Security=True"
providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<caching>
<sqlCacheDependency enabled="true" pollTime="2000">
<databases>
<add connectionStringName="ConnectionString1"
name="KJ"/>
</databases>
</sqlCacheDependency>

</caching>

I have added this into global.asax file for the application start event:
System.Data.SqlClient.SqlDependency.Start(Configur ationManager.ConnectionStrings("ConnectionString1" ).ToString())

Then I wrote this code where I get data from the table MAAKUNNAT in the
database.
----------
SqlCacheDependencyAdmin.EnableTableForNotification s(ConfigurationManager.ConnectionStrings("Connecti onString1").ToString(),
"MAAKUNNAT")
Dim maakunnatDS As New DataSet

If Cache.Get("maakunnat") Is Nothing Then
Dim myConnection As New
SqlConnection(ConfigurationManager.ConnectionStrin gs("ConnectionString1").ToString())
myConnection.Open()

Dim cmd As New SqlCommand("haemaakunnat", myConnection)
cmd.CommandType = CommandType.StoredProcedure
Dim riippuvuus As New SqlCacheDependency("KJ", "MAAKUNNAT")
Dim aggDep As New AggregateCacheDependency
aggDep.Add(riippuvuus)

Dim maakunnatDA As SqlDataAdapter = New SqlDataAdapter
maakunnatDA.SelectCommand = cmd

maakunnatDA.Fill(maakunnatDS, "MAAKUNTA")
myConnection.Close()
Cache.Insert("maakunnat", maakunnatDS, aggDep)

Else
Response.Write("The data is in the cache")
maakunnatDS = Cache.Get("maakunnat")
End If
-----------------
When I run the page I get this error.
------------------------------------------

The 'MAAKUNNAT' table in the database 'KJ' is not enabled for SQL cache
notification.

Please make sure the table exists, and the table name used for cache
dependency matches exactly the table name used in cache notification
registration.

To enable a table for SQL cache notification, please use
SqlCacheDependencyAdmin.EnableTableForNotification s method, or the command
line tool aspnet_regsql. To use the tool, please run 'aspnet_regsql.exe -?'
for more information.

To get a list of enabled tables in the database, please use
SqlCacheDependencyManager.GetTablesEnabledForNotif ications method, or the
command line tool aspnet_regsql.exe.
----------------------------------------------
When I run the aspnet_regsql tool with the -lt parameter to get a list of
enabled tables in the database they are all enabled. Thank you very much in
advance if someone could help me with this problem.

Toni S.
Aug 17 '07 #1
0 1235

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

Similar topics

2
by: Dave Griffiths | last post by:
Hi all Very new to JavaScript, I am trying to cache a number of images as the page loads, is there a max number of images or memory usage before the browser stops caching. My PC has 1G ram so...
0
by: Martin | last post by:
Hi. I had a very frustrating afternoon and evening but I have got it all under control now so all of a sudden I am in a good mood. I want to share some insights on output caching with you lot. ...
10
by: Jon Maz | last post by:
Hi, My goal is to take the entire html/javascript stream spat out by .aspx pages and save them as simple strings in a database (for caching purposes). I'm not sure how I can get hold of this...
8
by: tshad | last post by:
I am having a problem with IE on one machine where it will not work after the first time on certain pages. It appears to be going to the cache all the time. On other machines I don't have that...
17
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...
5
by: Raj | last post by:
What is the purpose of file system caching while creating a tablespace? Memory on the test server gets used up pretty quickly after a user executes a complex query(database is already activated),...
28
by: Peter Michaux | last post by:
Hi, I'm playing with dynamic script insertion to make a request to the server for a JavaScript file to be automatically run when it arrives in the browser. It works but... The page caching...
2
by: Toni | last post by:
Hello! I'm trying to use ASP.NET caching with my web site and SQL Server, but I have a problem. I try to do everything according to the instructions like this page here:...
6
by: John Kotuby | last post by:
Hi all, I am trying to get an ASPX page written in VB and VS 2008 to open more quickly inside of am Iframe in a standard HTML page. One of the things the page does is to allow users to click a...
0
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
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.