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.

Signature
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!
************************************************
> Hello! I'm trying to use ASP.NET caching with my web site and SQL Server,
> but I have a problem.
[quoted text clipped - 60 lines]
>
> Toni
Toni - 17 Aug 2007 10:50 GMT
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.EnableTableForNotifications(ConfigurationManager.ConnectionStrings("ConnectionString1").ToString(),
"MAAKUNNAT")
Dim maakunnatDS As New DataSet
If Cache.Get("maakunnat") Is Nothing Then
Dim myConnection As New
SqlConnection(ConfigurationManager.ConnectionStrings("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(ConfigurationManager.ConnectionStrings("ConnectionString1").ToString())
I still get the same error.
Toni S:
"Cowboy (Gregory A. Beamer)" <NoSpamMgbworld@comcast.netNoSpamM> kirjoitti
viestissä:O%23NkuPO3HHA.2312@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
[quoted text clipped - 65 lines]
>>
>> Toni