- IDataReader reader = command.ExecuteReader();
- int i = 0;
- while (reader.Read() && i < sliderSize)
- {
- int id = Convert.ToInt32(reader["ID"]);
- string pic = reader["PIC"].ToString();
- string title = reader["TITLE"].ToString();
- _rvl.Add(new ADsInfo { ID = id, PIC = pic, TITLE = title });
- i++;
- }
- DataTable dt = db.CenterSlidePlayerAd();
- DataRow[] rootRows = dt.Select();
- foreach (DataRow dr in rootRows)
- {
- int id = Convert.ToInt32(dr["ID"]);
- string pic = dr["PIC"].ToString();
- string title = dr["TITLE"].ToString();
- _rvl.Add(new ADsInfo { ID = id, PIC = pic, TITLE = title });
- if ((++i) > (sliderSize - 1))//取5条广告,sliderSize=5
- break;
- }