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];