本次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]; |
免责声明:本站部分文章和图片均来自用户投稿和网络收集,旨在传播知识,文章和图片版权归原作者及原出处所有,仅供学习与参考,请勿用于商业用途,如果损害了您的权利,请联系我们及时修正或删除。谢谢!
始终以前瞻性的眼光聚焦站长、创业、互联网等领域,为您提供最新最全的互联网资讯,帮助站长转型升级,为互联网创业者提供更加优质的创业信息和品牌营销服务,与站长一起进步!让互联网创业者不再孤独!
扫一扫,关注站长网微信