简要咨询咨询QQ网站导航网站搜索手机站点联系我们设为首页加入收藏 

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

来源:易贤网   阅读:718 次  日期:2014-10-30 08:29:26

温馨提示:易贤网小编为您整理了“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];

更多信息请查看IT技术专栏

更多信息请查看数据库
点此处就本文及相关问题在本站进行非正式的简要咨询(便捷快速)】     【点此处查询各地各类考试咨询QQ号码及交流群
上一篇:php输出xml必须header的解决方法
下一篇:从mdf|ldf文件恢复sqlserver数据库
易贤网手机网站地址:access如何模糊参数进行分页查询代码
由于各方面情况的不断调整与变化,易贤网提供的所有考试信息和咨询回复仅供参考,敬请考生以权威部门公布的正式信息和咨询为准!