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

语法错误。 在查询表达式 'ID not in (select top 12*1 ID from prod_news order by infotime des
/// <summary>
  /// 产品分页展示
  /// </summary>
  /// <param name="pagesize">每页显示多少条</param>
  /// <param name="pageindex">当前第几页</param>
  /// <returns>返回List<prod_news>集合</returns>
  public List<prod_news> ProductFenYe(int pagesize, int pageindex)
  {
  try
  {
  string sqlStr = "select top 12 * from prod_news where ID not in (select top "+pagesize+"*"+pageindex+" ID from prod_news order by infotime desc) order by infotime desc ";
  OleDbCommand cmd = new OleDbCommand(sqlStr, con);
  OleDbParameter par1 = new OleDbParameter("@pagesize", OleDbType.Integer);
  OleDbParameter par2 = new OleDbParameter("@pageindex", OleDbType.Integer);
  par1.Value = pagesize;
  par2.Value = pageindex;
  cmd.Parameters.Add(par1);
  cmd.Parameters.Add(par2);
  List<prod_news> list = new List<prod_news>();
  con.Open();
  OleDbDataReader reader = cmd.ExecuteReader();
  while (reader.Read())
  {
  prod_news prod_news = new prod_news();
  prod_news.ID = Convert.ToInt32(reader["ID"]);
  prod_news.title = reader["title"].ToString();
  prod_news.content = reader["content"].ToString();
  prod_news.ClassName = reader["ClassName"].ToString();
  prod_news.img = reader["img"].ToString();
  prod_news.okay2 = Convert.ToInt32(reader["okay2"]);
  prod_news.okay = Convert.ToInt32(reader["okay"]);
  prod_news.infotime = Convert.ToDateTime(reader["infotime"]);
  prod_news.hits = Convert.ToInt32(reader["hits"]);
  prod_news.ok = Convert.ToBoolean(reader["ok"]);
  list.Add(prod_news);
  }
  return list;
  }



各位:我刚使用这个ACCESS 数据库做项目,目前做分页老是有这个问题;求解啊 ;最好能给我的那个分页语句改改;我不会ACCESS;谢谢

------解决方案--------------------
top "+pagesize+"*"+pageindex+" 这什么状况?

为什么*要加引号变成字符串,这还能算出值来吗?