怎样才能有一个组合框,其中包含数据库中特定列的所有值.我有一个名为列的列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)
我该怎么办?请提供一些代码以继续这些代码,任何帮助将不胜感激.
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中从数据库中读取此填充日期
| 归档时间: |
|
| 查看次数: |
136 次 |
| 最近记录: |