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];
相关文章:
1. Access字符串处理函数整理2. Access数据库出现“无法保存;正被别的用户锁定”的原因3. Access日期与时间函数汇总4. Access数据库提示OleDbException (0x80004005): 操作必须使用一个可更新的查询5. C# 连接Access数据时总报找不到dbo.mdb的问题6. Microsoft Office Access隐藏和显示字段的方法7. ADODB连接access是出现 80004005 错误的解决方法8. Microsoft Office Access冻结字段的方法9. Microsoft Office Access将单元格效果设置为凸起的方法10. Microsoft Office Access修改代码字体大小的方法