问题描述
我正在集成SqlCacheDependency以在LinqToSQL数据上下文中使用.
I am integrating SqlCacheDependency to use in my LinqToSQL datacontext.
我正在对此处的Linq查询使用扩展类- http://code.msdn.microsoft. com/linqtosqlcache
I am using an extension class for Linq querys found here - http://code.msdn.microsoft.com/linqtosqlcache
我已经整理好代码,打开页面时出现此异常-
I have wired up the code and when I open the page I get this exception -
当前数据库的SQL Server Service Broker未启用,因此不支持查询通知.如果要使用通知,请为此数据库启用Service Broker."
"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."
它来自global.asax中的此事件
its coming from this event in the global.asax
protected void Application_Start()
{
RegisterRoutes(RouteTable.Routes);
//In Application Start Event
System.Data.SqlClient.SqlDependency.Start(new dataContextDataContext().Connection.ConnectionString);
}
我的问题是...
-
如何在SQL Server 2008数据库中启用Service Broker?我试图运行此查询.ALTER DATABASE表名SET ENABLE_BROKER但它永远不会结束并永远运行,我必须手动停止它.
how do i enable Service Broker in my SQL server 2008 database? I have tried to run this query.. ALTER DATABASE tablename SET ENABLE_BROKER but it never ends and runs for ever, I have to manually stop it.
一旦在SQL Server 2008中设置了此设置,它将过滤到我的DataContext,还是我也需要在此配置一些内容?
once I have this set in SQL server 2008, will it filter down to my DataContext, or do I need to configure something there too ?
感谢您的帮助
特鲁吉利
推荐答案
好的,如果禁用了备份或需要恢复备份(似乎已禁用了备份),那么如何执行此操作.
ok here is how to do this if yours is disabled or you need to restore a backup, which seems to disable it.
仅运行此脚本,它将杀死数据库正在使用的所有进程(为什么您要在2008年手动终止与2005年不同的进程,这超出了我的理解),然后设置代理
just run this script, it will kill all the process's that a database is using (why you carnt in 2008 manually kill process's unlike 2005 is beyond me) and then set the broker
USE master
go
DECLARE @dbname sysname
SET @dbname = 'YourDBName'
DECLARE @spid int
SELECT @spid = min(spid) from master.dbo.sysprocesses where dbid = db_id(@dbname)
WHILE @spid IS NOT NULL
BEGIN
EXECUTE ('KILL ' + @spid)
SELECT @spid = min(spid) from master.dbo.sysprocesses where dbid = db_id(@dbname) AND spid > @spid
END
ALTER DATABASE @dbname SET ENABLE_BROKER
这篇关于在SQL Server 2008中启用Service Broker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!