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

C# winfrom中一个Combobox控件中绑定两个数据集 代码如下
   private void InitStationCbo()
        {
            MySqlConnection con = DB.Connection;
            MySqlCommand cmd = null;
            MySqlDataReader dr_station = null;
            MySqlDataReader dr_proid = null;
            MySqlDataReader dr_lotid = null;
            using (con)
            using (cmd = con.CreateCommand())
            {
                cmd.Connection = con;
                con.Open();
                cmd.CommandText = string.Format("select station_id,station_testclass_id ,station_testclass_name from station_attributes,test_stations " 
                  +  " where station_attributes.station_class =test_stations.station_testclass_id  ");
                dr_station = cmd.ExecuteReader();
                #region dr_station
                using (dr_station)
                {
                    if (!dr_station.HasRows)
                    {
                        cboStationClass.DataSource = returnval_s;
                        cboStationClass2.DataSource = returnval_c;
                    }
                    else
                    {
                        while (dr_station.Read())
                        {
                            returnval_s.Add(dr_station.GetInt32("station_id"));