您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息
免费发信息

Access 模糊参数 分页查询

2024/3/28 21:57:39发布6次查看
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];
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录