代码如下
private void Form2_Load(object sender, EventArgs e)
{
string connString = "server=.;database=MyProject;uid=sa;pwd=";
SqlConnection conn = new SqlConnection(connString);
string sql = "select * from 学生基本信息";
DataSet ds = new DataSet();
SqlDataAdapter adapter = new SqlDataAdapter(sql, conn);
adapter.Fill(ds, "学生基本信息");
comboBox2.DataSource = ds.Tables["学生基本信息"];
comboBox3.DataSource = ds.Tables["学生基本信息"];
comboBox4.DataSource = ds.Tables["学生基本信息"];
comboBox5.DataSource = ds.Tables["学生基本信息"];
comboBox6.DataSource = ds.Tables["学生基本信息"];
comboBox7.DataSource = ds.Tables["学生基本信息"];
comboBox8.DataSource = ds.Tables["学生基本信息"];
comboBox2.DisplayMember = "籍贯";
comboBox3.DisplayMember = "院系";
comboBox4.DisplayMember = "专业";
comboBox5.DisplayMember = "年级";
comboBox6.DisplayMember = "班级";
comboBox7.DisplayMember = "学制";
comboBox8.DisplayMember = "民族";
}
显示到是显示出来了。但是comboBox 里有很多重复数据。我想问下怎么清除重复数据。显示一个就可以了
用distinct没有效果 因为这些数据都在一个表上