本次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]; |
免責聲明:本站部分文章和圖片均來自用戶投稿和網絡收集,旨在傳播知識,文章和圖片版權歸原作者及原出處所有,僅供學習與參考,請勿用于商業用途,如果損害了您的權利,請聯系我們及時修正或刪除。謝謝!
始終以前瞻性的眼光聚焦站長、創業、互聯網等領域,為您提供最新最全的互聯網資訊,幫助站長轉型升級,為互聯網創業者提供更加優質的創業信息和品牌營銷服務,與站長一起進步!讓互聯網創業者不再孤獨!
掃一掃,關注站長網微信