2

SQL Server 2012 でクエリ通知を機能させようとしています。このリンクのチュートリアルに従っていました: http://www.codeproject.com/Articles/144344/Query-Notification-using-SqlDependency-and-SqlCach

最終的には、OnChange イベントが常に発生します。SqlNotificationEventArgs には、Info=Invalid、Source=Statement、Type=Subscribe と表示されます。

私の調査によると、サブスクライブに問題があることがわかりましたが、その理由はわかりません。SQL Server イベント ログでは、取得するのは

The query notification dialog on conversation handle '{D30D3675-9A2F-E311-A141-8851FB594FAA}.' closed due to the following error: 
'<?xml version="1.0"?><Error xmlns="http://schemas.microsoft.com/SQL/ServiceBroker/Error"><Code>-8470</Code><Description>Remote service has been dropped.</Description></Error>'.

2 部構成のテーブル名を使用していることや、クエリが禁止されていることをしていないことを確認するなど、よくある懸念事項を確認しました。イベントを設定するコードは次のとおりです。

 public DataTable RegisterDependency()
 {
     this.CurrentCommand = 
           new SqlCommand("Select CategoryID,CategoryName,Description from dbo.[Categories]", this.CurrentConnection);

     this.CurrentCommand.Notification = null;


     SqlDependency dependency = new SqlDependency(this.CurrentCommand);
     dependency.OnChange += this.dependency_OnChange;

     if (this.CurrentConnection.State == ConnectionState.Closed)
         this.CurrentConnection.Open();

         try
         {
             DataTable dt = new DataTable();
             dt.Load(this.CurrentCommand.ExecuteReader(CommandBehavior.CloseConnection));
             return dt;
         }
         catch { return null; }

}

次に何をチェックしようか迷っています。どんな助けでも大歓迎です。

4

2 に答える 2

0

将来の読者のために。

Closed event notification conversation endpoint with handle '{ABC123}', due to the following error: '<?xml version="1.0"?><Error xmlns="http://schemas.microsoft.com/SQL/ServiceBroker/Error"><Code>-8470</Code><Description>Remote service has been dropped.</Description></Error>'.

データベース接続値<NotificationService><ConnectionString>と一致しなかったときに、このエラーが発生しました。<ApplicationService><OnNotification>(小さなタイプミスですが、捨てるには十分です)

于 2016-03-14T19:36:29.610 に答える
0

問題はテーブル定義にあったことが判明しました。「説明」列は「ntext」タイプであり、通知では機能しません。

于 2013-10-14T20:50:09.653 に答える