首页 > 数据库 > Access

Access 模糊参数 分页查询

admin Access 2022-02-10 06:54:27 Access   模糊参数   分页查询"

复制代码 代码如下:
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];

版权声明

本文仅代表作者观点,不代表本站立场。
本文系作者授权发表,未经许可,不得转载。
本文地址:/shujuku/Access/101839.html

留言与评论(共有 0 条评论)
   
验证码:

潘少俊衡

| 桂ICP备2023010378号-4

Powered By EmpireCMS

爱享小站

中德益农

谷姐神农

环亚肥料

使用手机软件扫描微信二维码

关注我们可获取更多热点资讯

感谢潘少俊衡友情技术支持