复制代码 代码如下:
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];
相关文章:
1. 如何让access自动编号从1开始排序实现方法2. access不能打开注册表关键字错误处理方法(80004005错误)3. Access数据库不能写不能更新的解决方法4. Access连接数据源(ODBC)配置(新手必知)5. 用SQL语句查找Access中某表是否存在的小技巧6. access中显示MSysObjects系统表的设置方法7. 搭建小型access数据库实录8. 自己动手把ACCESS转换到SQLSERVER的方法9. Access数据库提示OleDbException (0x80004005): 操作必须使用一个可更新的查询10. ACCESS数据库修改自动编号的ID值为零的方法分享