Access Fuzzy Parameter paging Query

Source: Internet
Author: User

CopyCode The Code is as follows: 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];

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.