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

System.IndexOutOfRangeException: summary
DAL代码如下:

  public Video GetEntity(int Id)
  {
  Video video = new Video();
  Database database = DatabaseFactory.CreateDatabase();
  string sql = "select title,keywords,file_name,remark,is_show,order_by,image,alt,create_date from video where Id=@Id";
  DbCommand cmd = database.GetSqlStringCommand(sql);
  database.AddInParameter(cmd, "@Id", DbType.Int32, Id);
  using (IDataReader reader = database.ExecuteReader(cmd))
  {
  if (reader.Read())
  {
  video.Id = Id;
  video.Title = reader["title"].ToString();
  video.Keywords = reader["summary"].ToString();
  video.FileName = reader["content"].ToString();
  video.Remark = reader["click_number"].ToString();
  video.IsShow = bool.Parse(reader["keywords"].ToString());
  video.OrderBy = int.Parse(reader["order_by"].ToString());
  video.Image = reader["image"].ToString();
  video.Alt = reader["alt"].ToString();
  video.CreateDate = DateTime.Parse(reader["create_date"].ToString());
  }
  }
  return video;
  }
BLL代码如下:

namespace shuipeijian.BLL
{
  public class VideoBusiness
  {
  public bool Add(Video video)
  {
  return new VideoDAO().Add(video);
  }
  public bool Delete(int Id)
  {
  return new VideoDAO().Delete(Id);
  }
  public bool Update(Video video) 
  {
  return new VideoDAO().Update(video); 
  }
下面这个是BLL ,对应上面那个DAL
  public Video GetEntity(int Id) 
  {
  return new VideoDAO().GetEntity(Id); 
  }


UI层如下:
 private void DataRead()
  {
  int id = int.Parse(Request.QueryString["Id"]);
  VideoBusiness newsContentBusiness = new VideoBusiness();
  Video v = newsContentBusiness.GetEntity(id);---这里出错!我的vs没法调试。。。
  displayInfo(v);


  }
  private void displayInfo(Video newsContent)
  {
  txtTitle.Text = newsContent.Title;
  txtOrderBy.Text = newsContent.OrderBy.ToString();
  ddlCategory.SelectedItem.Text = newsContent.Alt.ToString();
  chkIsShow.Checked = newsContent.IsShow;
  txtKeywords.Text = newsContent.Keywords;
  txtContent.Value = newsContent.Remark;
  }


能帮我看看那儿出错啊

------解决方案--------------------
找这个方法GetEntity

索引超出范围!
------解决方案--------------------
索引越界了。。