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

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

来源:易贤网   阅读:622 次  日期:2014-10-22 10:02:28

温馨提示:易贤网小编为您整理了“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号码及交流群
上一篇:Access怎样制作复杂报表
下一篇:Access提高企业管理器功能
易贤网手机网站地址:Access如何模糊参数进行分页查询代码
由于各方面情况的不断调整与变化,易贤网提供的所有考试信息和咨询回复仅供参考,敬请考生以权威部门公布的正式信息和咨询为准!