title: Populating textbox with mysql data values from combobox selection c#
body: <p>I am trying to populate my text boxes with the values in my database so when a user selects a name of a teacher from the combobox, the text-boxes will populate with their contact details. This is the code I have so far. There are no errors however the textboxes are still blank when I select a value from combo box.</p>
  
  <pre><code>    private void comboBox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
      {
          MySqlConnection cs = new MySqlConnection(connectionSQL);
          cs.Open();
  
          DataSet ds = new DataSet();
  
          MySqlDataAdapter da = new MySqlDataAdapter("Select * from Teacher WHERE name='" + comboBox1.Text + "'", cs);
  
          MySqlCommandBuilder cmd = new MySqlCommandBuilder(da);
  
          da.Fill(ds);
  
  
          if (comboBox1.SelectedIndex &gt; 0)
          {
  
  
              NameBox.Text = ds.Tables[0].Rows[0]["name"].ToString();
              AddressBox.Text = ds.Tables[0].Rows[0]["address"].ToString();
  
          }
  </code></pre>
  
  <p>Any help or advice would be greatly appreciated</p>