SQL Server service broker reporting as off when I have written a query to turn it on

asp.netsql serversql-server-2005

I have made a small ASP.NET website. It uses sqlcachedependency

The SQL Server Service Broker for the current database is not enabled, and as a result query notifications are not supported. Please enable the Service Broker for this database if you wish to use notifications.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: The SQL Server Service Broker for the current database is not enabled, and as a result query notifications are not supported. Please enable the Service Broker for this database if you wish to use notifications.

Source Error:

Line 12: System.Data.SqlClient.SqlDependency.Start(connString);

This is the erroneous line in my global.asax.

However, in sql server (2005), I enabled service broker like so (I connect and run the SQL Server service when I debug my site):

ALTER DATABASE mynewdatabase SET ENABLE_BROKER with rollback immediate

And this was successful.

What am I missing? I am trying to use sql caching dependency and have followed all procedures.

Thanks

Best Answer

I faced the same problem on one of our servers. this solved the issue (replace DBNAME with database name)

ALTER DATABASE DBNAME SET NEW_BROKER WITH ROLLBACK IMMEDIATE;

ALTER DATABASE DBNAME SET ENABLE_BROKER;

Finally, check whether you get 1 for is_broker_enabled flag:

SELECT is_broker_enabled FROM sys.databases WHERE name = 'DBNAME'