DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Fri, 17 Aug 2007 10:36:55 +0300,    posted on: microsoft.public.dotnet.framework.aspnet        back       

Thread Index
  1    Toni


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(ConfigurationManager.ConnectionStrings("ConnectionString1").ToString())

Then I wrote this code where I get data from the table MAAKUNNAT in the 
database.
----------
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
-----------------
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.EnableTableForNotifications 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.GetTablesEnabledForNotifications 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.
Date:Fri, 17 Aug 2007 10:36:55 +0300   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us