title: Fill Combobox from database
body: <p>I have an error with a combobox </p>
  
  <p>My code:</p>
  
  <pre><code>SqlConnection conn = new SqlConnection();
  try
  {
      conn = new SqlConnection(@"Data Source=SHARKAWY;Initial Catalog=Booking;Persist Security Info=True;User ID=sa;Password=123456");
      string query = "select FleetName, FleetID from fleets";
      SqlCommand cmd = new SqlCommand(query, conn);
      cmd.CommandText = query;
      conn.Open();
      SqlDataReader drd = cmd.ExecuteReader();
      while (drd.Read())
      {
           cmbTripName.Items.Add(drd["FleetName"].ToString());
           cmbTripName.ValueMember = drd["FleetID"].ToString();
           cmbTripName.DisplayMember = drd["FleetName"].ToString();
      }
  }
  catch
  {
       MessageBox.Show("Error ");
  }
  </code></pre>
  
  <p>The data is presented in the combobox, but when you <strong>change the selection valuemember the displaymember does not change.</strong></p>
  
  <p>It's working now but when I click the button to show the data</p>
  
  <pre><code>private void button1_Click(object sender, EventArgs e)
  {
      label1.Text = cmbTripName.DisplayMember;
      label2.Text = cmbTripName.ValueMember;
  }
  </code></pre>
  
  <p>This is displayed:</p>
  
  <p>FleetName<br>
  FleetID</p>
  
  <p>It does not display the value </p>