title: binding combobox with data and save as foreign key c#
body: <p>I am writing an application for the applicants of universities using c#. On the first form I have several textboxes ,radiobutton and a combo box.   All these are related to a database (student) that i create. There is a <code>table tbl_nationality</code> and a table <code>tblstudent</code> in the database. In the table <code>tbl_nationality</code> we have the column <code>Nationality_id</code> and <code>Country</code>. The <code>nationality_id</code> is a foreign key in the table <code>tblstudent</code> .</p>
  
  <p>I wrote some lines of code to populate the data from the column country in the combo box (cmbnationality) . The problem is, now I need to save the data from the forms and the combo box nationality is a foreign key in the table tblstudent. How do I do to save the foreign key <code>nationality_id</code> in tblstudent when I am displaying the country from <code>tbl_nationality</code>.</p>
  
  <pre><code>void FillNationality()
  {
      SqlConnection connection = new SqlConnection();
      connection.ConnectionString = "Integrated Security=true; Initial Catalog = student; Data Source = Yudish-PC";
      string Query = "select * from tbl_nationality ;";
      SqlCommand cmdDatabase = new SqlCommand(Query, connection);
      SqlDataReader myReader;
      try
      {
          connection.Open();
          myReader = cmdDatabase.ExecuteReader();
          while (myReader.Read())
          {
            string nationality = myReader.GetString (1);
              cmbnationality.Items.Add(nationality);
          }
      }
      catch (Exception ex)
      {
          MessageBox.Show(ex.Message);            
      }
      finally
      {
          connection.Close();
      }
  }
  </code></pre>