Access如何模糊參數(shù)進行分頁查詢代碼
來源:易賢網(wǎng) 閱讀:796 次 日期:2014-08-21 14:21:42
溫馨提示:易賢網(wǎng)小編為您整理了“Access如何模糊參數(shù)進行分頁查詢代碼”,方便廣大網(wǎng)友查閱!

代碼如下:

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技術專欄

更多信息請查看數(shù)據(jù)庫
易賢網(wǎng)手機網(wǎng)站地址:Access如何模糊參數(shù)進行分頁查詢代碼
關于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 加入群交流 | 手機站點 | 投訴建議
工業(yè)和信息化部備案號:滇ICP備2023014141號-1 云南省教育廳備案號:云教ICP備0901021 滇公網(wǎng)安備53010202001879號 人力資源服務許可證:(云)人服證字(2023)第0102001523號
聯(lián)系電話:0871-65317125(9:00—18:00) 獲取招聘考試信息及咨詢關注公眾號:hfpxwx
咨詢QQ:526150442(9:00—18:00)版權所有:易賢網(wǎng)