title: C# Update label real time from database
body: <p>What is a good way to update a label on your winforms by fetching result from the database. So all users get the update real time instead for starting the winform over to get the update.</p>
  
  <pre><code>    public partial class labelControl : UserControl
  {
      public labelControl()
      {
          InitializeComponent();
          updateLabel();
      }
  
      private void updateLabel()
      {
          using (Database.sqlConnection = new SqlConnection(Database.connectionString))
          {
              Database.sqlConnection.Open();
              string selectQuery = "SELECT * FROM Information";
  
              using (SqlCommand sqlCommand = new SqlCommand(selectQuery, Database.sqlConnection))
              {
                  using (SqlDataReader sqlReader = sqlCommand.ExecuteReader())
                  {
                      if (sqlReader.HasRows)
                      {
                          while (sqlReader.Read())
                          {
                              label1.Text = sqlReader["Text"].toString();
                          }
                      }
                  }
              }
          }
      }
  }
  </code></pre>