473,394 Members | 1,811 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,394 software developers and data experts.

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

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:
http://www.eggheadcafe.com/articles/20060407.asp

First I run the aspnet_regsql tool on the command line succesfully to enable
the database for cache notification:
aspnet_regsql -S [SERVER] -E -d [database] -ed

Then I run the following command on the command line succesfully for each
table in the database:
aspnet_regsql -S [SERVER] -E -d [database] -et -t [table]

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

<connectionStrings>
<add name="ConnectionString1"
connectionString="Server=servername;Database=datab asename;Trusted_Connection=yes"
/>
</connectionStrings>

<caching>
<sqlCacheDependency enabled="true" pollTime="2000">
<databases>
<add connectionStringName="ConnectionString1"
name="KJ"/>

</databases>
</sqlCacheDependency>
</caching>

Then I added the following line into the beginning of the page default.aspx
<%@ OutputCache Duration="86400" VaryByParam="*"
SqlDependency="KJ:ILMOITUKSET" %>

But when I run the page default.aspx it gives the following error:
-----------------------------
The 'ILMOITUKSET' 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 aspnet_regsql.exe with the -lt parameter to see the list of
tables that are enabled for cache notification they are all enabled. Could
someone help me with this problem and tell me what I'm doing wrong? Thank
you so much in advance.

Toni

Aug 12 '07 #1
2 1987
First, are you using SQL Server 7 or 2000? They use the version of caching
you talk about. If you are using SQL Server 2005, it is automatic when you
use the SQLCacheDependency instead.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com
Co-author: Microsoft Expression Web Bible (upcoming)

************************************************
Think outside the box!
************************************************
"Toni" <no****@hotmail555.comwrote in message
news:OC**************@TK2MSFTNGP02.phx.gbl...
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:
http://www.eggheadcafe.com/articles/20060407.asp

First I run the aspnet_regsql tool on the command line succesfully to
enable the database for cache notification:
aspnet_regsql -S [SERVER] -E -d [database] -ed

Then I run the following command on the command line succesfully for each
table in the database:
aspnet_regsql -S [SERVER] -E -d [database] -et -t [table]

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

<connectionStrings>
<add name="ConnectionString1"

connectionString="Server=servername;Database=datab asename;Trusted_Connection=yes"
/>
</connectionStrings>

<caching>
<sqlCacheDependency enabled="true" pollTime="2000">
<databases>
<add connectionStringName="ConnectionString1"
name="KJ"/>

</databases>
</sqlCacheDependency>
</caching>

Then I added the following line into the beginning of the page
default.aspx
<%@ OutputCache Duration="86400" VaryByParam="*"
SqlDependency="KJ:ILMOITUKSET" %>

But when I run the page default.aspx it gives the following error:
-----------------------------
The 'ILMOITUKSET' 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 aspnet_regsql.exe with the -lt parameter to see the list of
tables that are enabled for cache notification they are all enabled. Could
someone help me with this problem and tell me what I'm doing wrong? Thank
you so much in advance.

Toni

Aug 12 '07 #2
I am using SQL Server 2005 Express Edition. I tried to create the cache
programmatically. I removed the line

<%@ OutputCache Duration="86400" VaryByParam="*"
>SqlDependency="KJ:ILMOITUKSET" %>
and wrote the following code:

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

I added into global.asax line:
System.Data.SqlClient.SqlDependency.Start(Configur ationManager.ConnectionStrings("ConnectionString1" ).ToString())

I still get the same error.

Toni S:

"Cowboy (Gregory A. Beamer)" <No************@comcast.netNoSpamMkirjoitti
viestissä:O%****************@TK2MSFTNGP06.phx.gbl. ..
First, are you using SQL Server 7 or 2000? They use the version of caching
you talk about. If you are using SQL Server 2005, it is automatic when you
use the SQLCacheDependency instead.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com
Co-author: Microsoft Expression Web Bible (upcoming)

************************************************
Think outside the box!
************************************************
"Toni" <no****@hotmail555.comwrote in message
news:OC**************@TK2MSFTNGP02.phx.gbl...
>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:
http://www.eggheadcafe.com/articles/20060407.asp

First I run the aspnet_regsql tool on the command line succesfully to
enable the database for cache notification:
aspnet_regsql -S [SERVER] -E -d [database] -ed

Then I run the following command on the command line succesfully for each
table in the database:
aspnet_regsql -S [SERVER] -E -d [database] -et -t [table]

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

<connectionStrings>
<add name="ConnectionString1"

connectionString="Server=servername;Database=data basename;Trusted_Connection=yes"
/>
</connectionStrings>

<caching>
<sqlCacheDependency enabled="true" pollTime="2000">
<databases>
<add connectionStringName="ConnectionString1"
name="KJ"/>

</databases>
</sqlCacheDependency>
</caching>

Then I added the following line into the beginning of the page
default.aspx
<%@ OutputCache Duration="86400" VaryByParam="*"
SqlDependency="KJ:ILMOITUKSET" %>

But when I run the page default.aspx it gives the following error:
-----------------------------
The 'ILMOITUKSET' 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.EnableTableForNotificatio ns 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.GetTablesEnabledForNoti fications method, or the
command line tool aspnet_regsql.exe.
-----------------------------------
When I run aspnet_regsql.exe with the -lt parameter to see the list of
tables that are enabled for cache notification they are all enabled.
Could someone help me with this problem and tell me what I'm doing wrong?
Thank you so much in advance.

Toni


Aug 17 '07 #3

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

Similar topics

4
by: Jerome Cohen | last post by:
This problem is driving us mad, and I saw someone else posting a very similar problem, again no support from MS! ----------------------- Win2K/IIS 5.0, web farm load balanced by Local director....
8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
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. ...
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...
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...
5
by: Glen Buell | last post by:
Hi all, I have a major problem with my ASP.NET website and it's SQL Server 2005 Express database, and I'm wondering if anyone could help me out with it. This site is on a webhost...
4
by: Brad Isaacs | last post by:
I am working with ASP.NET 2.0 and using an SQL Server 2000 database. I am using Visual Studio 2005 and developing on my Local machine. I am working with Login controls ASP.Configuration, I...
3
by: TC | last post by:
Hey All, I have some classes that I recently built for a website which uses the HttpWebRequest & HttpWebResponse objects from the System.Net namespace. Basically, the classes rap submitted data...
0
by: Toni | last post by:
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
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...
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
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...
0
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,...
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...

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.