title: Polling for database changes: SqlDependency, SignalR is Good
body: <p>I need to show changes to data in a database through <code>SqlDependency</code> and SignalR. Suppose my transaction table is often changed by many people. Suppose in a few seconds, the data is changed many times, then I would like to know how notifications will go to the <code>SqlDependency</code> class ?</p>
  <p>Will change data be queued before <code>SqlDependency</code> class?</p>
  <p>Can the <code>SqlDependency</code> class handle data change when huge number of traffic will do the changes?</p>
  <p>I read <a href="http://techbrij.com/database-change-notifications-asp-net-signalr-sqldependency" rel="nofollow noreferrer">this article</a> on <code>SqlDependency</code> &amp; SignalR.</p>
  <p>A few things were not clear to me.</p>
  <ol>
  <li><p>How to give subscribe query notification permission to IIS?</p>
  </li>
  <li><p>Please see the line in this article.</p>
  <pre><code>private void dependency_OnChange(object sender, SqlNotificationEventArgs e) {
      JobHub.Show();
  }
  </code></pre>
  </li>
  </ol>
  <p>When data is changed, then the <code>dependency_OnChange</code> event will fire and <code>JobHub.Show();</code> is called.</p>
  <p><code>JobHub</code> is the name of a class (not a static class), so I'd like to know how to call <code>JobHub.Show();</code> from outside?</p>
  <ol start="4">
  <li>What is the <code>GlobalHost</code> class and when it is used?</li>
  <li>The article code related issue. Just go to <a href="http://techbrij.com/database-change-notifications-asp-net-signalr-sqldependency" rel="nofollow noreferrer">this link</a>.</li>
  </ol>
  <p>See the jQuery code in the view that fetches data and populates a table. The first time when the page loads, suppose there are 5 records existing in the table, so 5 records will be passed to the jQuery code and it will just display those 5 records. But when any existing data will be changed in the table, then what will happen?</p>
  <p>Will only the changed rows come to client side, or will all data including the changed data come to client side?</p>
  <p>If you say only the changed data will, code then just see the video in that link. It is shown in the video data is changed one by one and change is reflecting at client end, but if you see the jQuery code it just empties the table first and builds the table again.</p>
  <p>So my question is, if the data is changed and only changed data will come, then one row should display at client side.... am I right? But in video the change is showing other data as well.</p>
  <p>So please read the link article once and then answer my question. Thanks.</p>