使用SqlDependency时要开启Service Broker ,那么SqlDependency是什么 https://www.cnblogs.com/zhaoyihao/p/5663258.html
如何启用 Service Broker:
--is_broker_enabled为0未启用,为1启用 SELECT name,is_broker_enabled FROM sys.databases WHERE name = 'DBNAME' ALTER DATABASE DbName SET NEW_BROKER WITH ROLLBACK IMMEDIATE; ALTER DATABASE DbName SET ENABLE_BROKER;
1.先查看是否开启
2.执行
3.再次查看