Hi,网页设计师综合门户欢迎您!
设为首页  加为收藏  我要投稿找回密码免责声明意见反馈

招聘精英个人求职推广网站网友作品网页特效动画欣赏网页素材酷站欣赏源码下载设计软件

  • 全站搜索
  • 新闻资讯
  • 网页教程
  • 平面教程
  • 程序设计
  • 视频教程
  • Flash教程

网页设计师提供网页设计、网站程序开发、系统开发等,请联系QQ 103198680

 您当前的位置:首页 > 阅读文章
网页设计师综合门户欢迎您!

Access如何模糊参数进行分页查询代码

刊登方式:转载   来源:网络  作者:  关键词:平面设计理念  更新时间:2017/7/9

   具体代码如下:

  string sql = "Select Count(ID) As rcount From TbProduct WHERE classID IN(" + ids + ") AND PRODUCTNAME LIKE '%'+@ProductName+'%'";

  OleDbParameter[] sps = new OleDbParameter[1];

  sps[0] = AccessDB.CreateParameter("@ProductName", OleDbType.VarChar, productName, 50, ParameterDirection.Input);

  int resultCount = (int)AccessDB.ExecuteScalar(sql, sps);

  recordCount = resultCount;

  if (resultCount >= 0)

  {

  if ((resultCount % pageSize) == 0)

  {

  pageCount = resultCount / pageSize;

  }

  else

  {

  pageCount = (resultCount / pageSize) + 1;

  }

  if (pageIndex == 1)

  {

  sql = "Select Top " + pageSize.ToString() + " * From TbProduct WHERE classID IN(" + ids + ") AND PRODUCTNAME LIKE '%'+@ProductName+'%' Order by ID desc";

  }

  else

  {

  int minRecord = (pageIndex - 1) * pageSize;

  sql = "Select Top " + pageSize.ToString() + " * From TbProduct Where ID Not In(Select ID From (Select Top " + minRecord.ToString() + " ID From tbProduct Where classID IN(" + ids + ") AND PRODUCTNAME LIKE '%'+@ProductName+'%' Order by ID desc )TemA) And classID IN(" + ids + ") AND PRODUCTNAME LIKE '%'+@ProductName+'%' Order by ID desc";

  }

  }

  else

  {

  pageCount = 0;

  }

  return AccessDB.ExecuteDataSet(sql, sps).Tables[0];