title: Populating Combobox from database dynamically
body: <p>I am working on a project for my college where I need to bind data from database into the combobox. I need to store the roll no / enrollment no in the "value" field of combobox and name of the student in the "text" property of the combobox.</p>
  
  <p>My code is :</p>
  
  <p>#region Fill Combo Box
          //Fill Combo Box.
          public static void FillCombo(ComboBox _cb, string _sSQL, string _sTable)
          {
              OleDbDataAdapter _oledbDA = new OleDbDataAdapter(_sSQL, _olbedbCN);
              DataTable _dtSource = new DataTable();
              _oledbDA.Fill(_dtSource);
              _cb.DataSource = _dtSource;
              _cb.ValueMember = _dtSource.Columns[0].ColumnName;
              _cb.DisplayMember = _dtSource.Columns[1].ColumnName;
          }</p>
  
  <h1>endregion</h1>
  
  <p>here::</p>
  
  <p><strong>_sSQL = "select rollno, studentname from student_data"</strong></p>
  
  <p>Other code i tried was :</p>
  
  <h1>region Fill Combo Box</h1>
  
  <pre><code>    //Fill Combo Box.
      public static void FillCombo(ComboBox _cb, string _sSQL, string _sTable)
      {
  
  
          OleDbDataAdapter _oledbDA = new OleDbDataAdapter("select rollno, studentname from student_data", _olbedbCN);
          DataTable _dtSource = new DataTable();
          _oledbDA.Fill(_dtSource);
          _cb.DataSource=ds.Tables["StudentData"];
          _cb.DisplayMember="Studentname";
          _cb.ValueMember="rollno";
          _cb.SelectedIndex=0;        }
  </code></pre>
  
  <p>}</p>
  
  <h1>endregion</h1>
  
  <p>but the problem is, nothing is been loaded in the combo box.... when i run the application, no error comes, but nothing is loaded in the combobox...</p>
  
  <p>Please help... its SOS...</p>