title: What is the right way to populate a DropDownList from a database?
body: <p>I am populating a DropDownList from a SQL Server database as shown below. It works fine, but I'm not sure it's a good way. Can someone shed some light on this method, and give some improvements?</p>
  
  <pre><code>private void LoadSubjects()
  {
      ddlSubjects.Items.Clear();
      string selectSQL = "SELECT SubjectID,SubjectName FROM Students.dbo.Subjects";
  
      SqlConnection con = new SqlConnection(connectionString);
      SqlCommand cmd = new SqlCommand(selectSQL, con);
      SqlDataReader reader;
  
      try
      {
          ListItem newItem = new ListItem();
          newItem.Text = "&lt;Select Subject&gt;";
          newItem.Value = "0";
          ddlSubjects.Items.Add(newItem);
  
          con.Open();
          reader = cmd.ExecuteReader();
          while (reader.Read())
          {
              newItem = new ListItem();
              newItem.Text = reader["SubjectName"].ToString();
              newItem.Value = reader["SubjectID"].ToString();
              ddlSubjects.Items.Add(newItem);
          }
          reader.Close();
      }
      catch (Exception err)
      {
          //TODO
      }
      finally
      {
          con.Close();
      }
  }
  </code></pre>