Friday, March 23, 2012

The SQL Server Service Broker for the current database is not enabled -when using SqlCacheDependency

I was in the process of using SqlSiteMapProvider class today by jeff which is a new feature of ASP.NET 2.0 and i have always wanted to try this out
My main goal is to have a database driven site navigation interface with a securitytrimming feature which i know is possible

But after running the sql script to insert some sample tables to the DB and setting upt the project in VS 2005.
Ran F5 to run a sample page  and bingo error:
The SQL Server Service Broker for the current database is not enabled

After doing some search i saw a post that said you just have to run the below from query analyzer:
ALTER DATABASE DatabaseName SET ENABLE_BROKER; 

But the query kept running for minutes and never stopped.So i taught there must be some conflicts.
So i started looking for a way to force the close off conflicting sessions.
So i ran
ALTER DATABASE DatabaseName SET NEW_BROKER WITH ROLLBACK IMMEDIATE;
and then
ALTER DATABASE Databasename SET ENABLE_BROKER;
and then the query ran successfully
make sure you run:
SELECT is_broker_enabled FROM sys.databases WHERE name = 'DatabaseName'

to get the correct value : is_broker_enabled = 1

No comments:

Post a Comment