组合框值c急剧变化

ali*_*mer 0 c# sql sql-server

怎样才能有一个组合框,其中包含数据库中特定列的所有值.我有一个名为列的列StudentName,我希望有一个组合框,其中包含所有值StudentName.

sql = new SqlConnection(@"Data Source=PC-PC\PC;Initial Catalog=Anbar;Integrated Security=True");
adapter = new SqlDataAdapter("select * from School", sql);
Run Code Online (Sandbox Code Playgroud)

我该怎么办?请提供一些代码以继续这些代码,任何帮助将不胜感激.

Hab*_*bib 5

sqlCon = new SqlConnection(@"Data Source=PC-PC\PC;Initial Catalog=Anbar;Integrated Security=True");
  SqlDataAdapter da = new SqlDataAdapter("Select StudentName from School", sqlCon);
        DataTable dt = new DataTable();
        da.Fill(dt);
        yourComboBox.DataSource = dt;
        yourComboBox.DisplayMember = "StudentName";
        yourComboBox.ValueMember = "StudentName";
Run Code Online (Sandbox Code Playgroud)

还可以在ComboBox中从数据库中读取此填充日期