title: SQLDependency_OnChange-Event fires only one single Time
body: <p>I'm working with SQLDependency to notify me if there is a change in the Database. 
  After Program Start-Up it works just fine. When I make a first change the Event fires. Wohoo... that's great. 
  But if I made a second change the event doesn't fire again. I've searched all the web I think but haven't found anything about THIS Problem. Only found problems where the OnChange-Event fires in a Loop.
  Can anyone help me?</p>
  
  <p>Here a little code piece:</p>
  
  <pre><code>private void GetStates()
      {
          if (!DoesUserHavePermission())
              return;
  
          SqlDependency.Stop(con);
          SqlDependency.Start(con);
  
          using (SqlConnection cn = new SqlConnection(con))
          {
              using (SqlCommand cmd = cn.CreateCommand())
              {
                  cmd.CommandType = CommandType.Text;
                  cmd.CommandText = "SELECT Bla, Bla2, ..FROM dbo.[BLA3]"
  
                  cmd.Notification = null;
                  cmd.Dispose();
  
                  SqlDependency dep = new SqlDependency(cmd);
                  dep.OnChange += new OnChangeEventHandler(dep_OnChange);
  
                  cn.Open();
  
                  using (SqlDataReader dr = cmd.ExecuteReader())
                  {
                      state.Clear(); //In this Case "state" is a List&lt;string&gt;
                      while (dr.Read())
                      {
                          state.Add(dr.GetString(0) + "|" + dr.GetInt32(3));
                      }
                      dr.Dispose();
                      dr.Close();
                  }                    
              }
          }
      }
  </code></pre>
  
  <p>my OnChange-Event looks like this:</p>
  
  <pre><code>private void dep_OnChange(object sender, SqlNotificationEventArgs e)
      {
          SqlDependency dep = sender as SqlDependency;
          dep.OnChange -= this.dep_OnChange;
  
          using (SqlConnection cn = new SqlConnection(con))
          {
              using (SqlCommand cmd = cn.CreateCommand())
              {
                  cmd.CommandType = CommandType.Text;
                  cmd.CommandText = "SELECT Bla, Bla2, ..FROM dbo.[BLA3]";
  
                  cmd.Notification = null;
  
                  if (e.Type == SqlNotificationType.Change)
                  {
                      if (cn.State != ConnectionState.Open)
                      {
                          cn.Open();
                      }
  
                      using (SqlDataReader dr = cmd.ExecuteReader())
                      {
                          state.Clear(); // Clear and Refill the stringlist "state"
                          while (dr.Read())
                          {
                              state.Add(dr.GetString(0) + "|" + dr.GetInt32(3));
                          }
                      }
                  }
                  cn.Close();
              }
          }
          this.GetStates(); //to go ahead and wait for a new change
      }
  </code></pre>
  
  <p>Where is the problem?</p>