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

Access如何模糊参数进行分页查询代码

2024/3/13 8:06:58发布18次查看
具体代码如下: 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, oled
具体代码如下:
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
企业名录 Product