设为首页 | 加入收藏
首页 bte365手机版
程序人生互联网新闻黑客新闻网络创业
WEB开发
PHPJSPASP.NETJavascriptAJAXjQueryNode.js
编程语言
JavaGolangPythonC++C语言VC++C#
站长之家
建站技巧网络赚钱网站安全
数据库
MySQLMSSQLSQLiteMongoDBRedisAccess存储技术
网页设计
HTML+DIV+CSSFlash网页制作技巧
网络技术
网络综合网络管理无线技术云计算云技术攻防知识安全防护
学电脑
电脑常识WindowsLinuxCPU内存显卡硬盘主板
学开发
开发总结365bet注册网站_365bet手机_365bet注册送18开发工具开发手册面试题
w3school
数据库 > Access >

Access 模糊参数 分页查询

发布时间:2015-11-26 | 阅读次数:763

代码如下:

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];