复制代码 代码如下:
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];
您可能感兴趣的文章:- Mysql中分页查询的两个解决方法比较
- 高效的SQLSERVER分页查询(推荐)
- 真正高效的SQLSERVER分页查询(多种方案)
- oracle,mysql,SqlServer三种数据库的分页查询的实例
- 三种SQL分页查询的存储过程代码
- php下巧用select语句实现mysql分页查询
- 防SQL注入 生成参数化的通用分页查询语句
- SQL Server 分页查询存储过程代码
- 数据库分页查询方法
- 分页查询 效率最高
- Ajax案例集下载:新增分页查询案例(包括《Ajax开发精要》中的两个综合案例) 下载
- 高效的jsp分页查询
- PHP 分页原理分析,大家可以看看
- php 分页原理详解
- 默默小谈PHPMYSQL分页原理及实现
- mysql分页原理和高效率的mysql分页查询语句