爱
爱睡的狗狗
Unregistered / Unconfirmed
GUEST, unregistred user!
各位高手:<br> 能不能给我一个完整的可以实现分页浏览的示例程序,就像有“显示全部信息,,分页显示,上一页,下一页”。<br> 我现在可以实现部分功能,可是上一页,下一页总是有bug,例如,第一次单击“下一页”时,显示的是单击“分页浏览”显示的内容(注一次显示5条记录),只有第二次单击“下一页”时才会增加。<br>这是源码,帮我看看那里有问题:<br><br>procedure TForm1.Button1Click(Sender: TObject); //显示全部信息<br> begin<br> with Query1 do<br> begin<br> Close;<br> SQL.Clear;<br> SQL.Add('select * from blacktable ORDER BY [NO]');<br> open;<br> end;<br> end;<br><br>procedure TForm1.Button2Click(Sender: TObject); //分页显示信息<br> begin<br> with Query1 do<br> begin<br> Close;<br> SQL.Clear;<br> sql.add('select top 5 * from blacktable where NO not in (select top 0 NO from blacktable)');<br> open;<br> end;<br>end;<br><br>procedure TForm1.Button3Click(Sender: TObject); //上一页<br> begin<br> with Query1 do<br> begin<br> Close;<br> SQL.Clear;<br> per_page_count:=5;<br> sql.add('select top '+inttostr(per_page_count)+' * from blacktable where NO not in (select top '+inttostr(PrevPageVariant)+' NO from blacktable)');<br> dec(PrevPageVariant,5);<br> open;<br> end;<br> end;<br><br>procedure TForm1.Button4Click(Sender: TObject); //下一页<br> begin with Query1 do<br> begin<br> Close;<br> SQL.Clear;<br> per_page_count:=5;<br> sql.add('select top '+inttostr(per_page_count)+' * from blacktable where NO not in (select top '+inttostr(PrevPageVariant)+' NO from blacktable)');<br> inc(PrevPageVariant,5);<br> open;<br> end;<br> end;