title: C# background worker sql
body: <p>I want to load a method which sets a number from database to a textfield using  a backgroundworker method...I tried days to find a way but still couldn't. When I call this method inside DoWork method nothing happens. </p>
  
  <p>This is the method;</p>
  
  <pre><code>        Int32 id = 0;
  
          string query = "SELECT MAX( CONVERT( SUBSTRING(RefNo, 3) , UNSIGNED INTEGER) ) FROM has.recruitments";
          MySqlConnection conDatabase = new MySqlConnection(constring);
          MySqlCommand cmdda = new MySqlCommand(query, conDatabase);
          MySqlDataReader myReader;
  
          try
          {
              conDatabase.Open();
  
              myReader = cmdda.ExecuteReader();
  
              while (myReader.Read())
              {
                  id = myReader.GetInt32(0);
              }
  
  
              if (!(Application.OpenForms.OfType&lt;Report&gt;().Any()))
              {
                  // MessageBox.Show("Opened");
  
                  int id1 = id + 1;
                  String s = "MP0" + id1;
  
                  //  MessageBox.Show(s);
                  textBox5.Text = s;
              }
  
          }
          catch (Exception ex)
          {
  
              MessageBox.Show(ex.Message);
          }
  </code></pre>