Tuesday, March 20, 2012

Cant enable SQLCacheDependency

I have a SQL 2005 database and am running the 2.0 framework. I cannot seem to enable SQL caching on the db. I'm using the command line tool as follows:

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727>aspnet_regsql -S 99.99.999.999 -U
webteam -P sa -t tblname -d dbname -et

Enabling the table for SQL cache dependency.

.An error has happened. Details of the exception:
The database 'dbname' is not enabled for SQL cache notification
.

To enable a database for SQL cache notification, please use the System.Web.Cachi
ng.SqlCacheDependencyAdmin.EnableNotifications method, or the command line tool
aspnet_regsql. To use the tool, please run 'aspnet_regsql.exe -?' for more infor
mation.


C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727>

I've replaced the ip address, dbname and tblname with ficticious names for obvious reasons here in the post.

What command can I enter to enable the database for caching?

Hi,

As show on the error message, you have to enable the cache notification on the whole database, using SqlCacheDependencyAdmin.EnableNotifications() method.

I can reproduce the error on my machine. And after calling this method, aspnet_regsql works fine.

HTH. If anything is unclear, please feel free to mark this post as Not Answered and post your reply. Thanks!

|||

Kevin, I'n not sure how to use the method you described. I tried to execute it from the command line as follows, but didn't work. It looks like I need to apply it in a .net program...

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727>SqlCacheDependencyAdmin.EnableNotifications(Data Source=99.99.999.999;Initial Catalog=dbname;UserID=id;Password=pswd)
'SqlCacheDependencyAdmin.EnableNotifications' is not recognized as an internal or external command,operable program or batch file.

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727>

How should I apply this method. Thanks so much...

|||

Kevin, I'n not sure how to use the method you described. I tried to execute it from the command line as follows, but didn't work. It looks like I need to apply it in a .net program...

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727>SqlCacheDependencyAdmin.EnableNotifications(Data Source=99.99.999.999;Initial Catalog=dbname;UserID=id;Password=pswd)
'SqlCacheDependencyAdmin.EnableNotifications' is not recognized as an internal or external command,operable program or batch file.

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727>

How should I apply this method. Thanks so much...

|||

Hi wsyeager,

This code is not executed from command line. It's a C# code.

You can create a project and execute this in the Form.Load event handler for a trial.

sql

No comments:

Post a Comment