日期:2014-05-17  浏览次数:20939 次

combobox 数据绑定代码纠错
C# code
sql = "select distinct * from planeinformation";
            da = new SqlDataAdapter(sql,DBHelper.Connection);
            st = new DataSet();
            da.Fill(st,"start");

            DataRow row = st.Tables["start"].NewRow();
            row["id"] = -1;
            row["setout"] = "请选择";
            st.Tables["start"].Rows.InsertAt(row,0);
            
            this.comboBox1.DataSource = st.Tables["start"];          
            this.comboBox1.DisplayMember = "setout";
            this.comboBox1.ValueMember = "id";
这段代码哪里错了 我绑定上去以后 仍然还是会有重复项出现很纠结啊

------解决方案--------------------
请不要用*,从你代码来看是需要setout不重复,那就对setout进行distinct即可

SQL code

select distinct(setout) as setout,id from planeinformation