title: SqlDependency.OnChange firing but SqlDataReader is not returning with data
body: <p>When I execute a query with a datetime column filter </p>
  
  <pre><code>WHERE [Order].CreatedOn &gt;= @CreatedOn
  </code></pre>
  
  <p>using a <code>SqlDependency</code>, the change on data source fires the <code>SqlDependency.OnChange</code> event but the <code>SqlDataReader</code> associated with the <code>SqlCommand</code> doesn't return data (<code>reader.HasRows</code> always returns <code>false</code>).</p>
  
  <p>When I just change the filter condition in my SQL statement to </p>
  
  <pre><code>WHERE [Order].StatusId = 1"
  </code></pre>
  
  <p>it just works fine and the <code>SqlDataReader</code> returns data (<code>reader.HasRows</code> returns <code>true</code>)</p>
  
  <p><strong>Code:</strong></p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Configuration;
  using System.Data;
  using System.Data.SqlClient;
  using System.Linq;
  using System.Web;
  using System.Web.UI;
  using System.Web.UI.WebControls;
  
  namespace SignalRServer
  {
      public partial class DepartmentScreen : System.Web.UI.Page
      {
          protected void Page_Load(object sender, EventArgs e)
          {
              var u = System.Security.Principal.WindowsIdentity.GetCurrent().User;
              var UserName = u.Translate(Type.GetType("System.Security.Principal.NTAccount")).Value;
  
              CheckForNewOrders(DateTime.Now);
          }
  
          private void CheckForNewOrders(DateTime dt)
          {
              string json = null;
              string conStr = ConfigurationManager.ConnectionStrings["connString"].ConnectionString;
  
              using (SqlConnection connection = new SqlConnection(conStr))
              {
                  string query = string.Format(@"
                          SELECT [Order].OrderId
                          FROM [dbo].[Order]
                          WHERE [Order].CreatedOn &gt;= @CreatedOn");
  
                  //                query = string.Format(@"
                  //                        SELECT [Order].OrderId
                  //                        FROM [dbo].[Order]
                  //                        WHERE [Order].StatusId = 1");
  
                  using (SqlCommand command = new SqlCommand(query, connection))
                  {
                      command.Parameters.Add("@CreatedOn", SqlDbType.DateTime);
                      command.Parameters["@CreatedOn"].Value = DateTime.Now;
  
                      command.Notification = null;
                      SqlDependency dependency = new SqlDependency(command);
                      dependency.OnChange += new OnChangeEventHandler(dependency_OnChange);
                      connection.Open();
                      SqlDataReader reader = command.ExecuteReader();
  
                      if (reader.HasRows)
                      {
                          reader.Read();
                          json = reader[0].ToString();
                      }
                  }
              }
  
              SignalRHub hub = new SignalRHub();
              hub.OrderReceived(json, null);
          }
  
          private void dependency_OnChange(object sender, SqlNotificationEventArgs e)
          {
              if (e.Type == SqlNotificationType.Change)
              {
                  CheckForNewOrders(DateTime.Now);
              }
              else
              {
                  //Do somthing here
                  //Console.WriteLine(e.Type);
              }
          }
      }
  }
  </code></pre>
  
  <p><strong>Images:</strong></p>
  
  <p><a href="https://i.stack.imgur.com/ag5rS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ag5rS.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/PaPaC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PaPaC.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/fMbSZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fMbSZ.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/uhRC2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uhRC2.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/57KjC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/57KjC.png" alt="enter image description here"></a></p>