hi all!
查询记录大概有1万多条,要分成几页显示,先显示500条数据 点击下一页按钮时显示后500条 如此功能如何实现?
谢谢!

解决方案 »

  1.   

    表加一个 ID ,Int ,标识自增var  i : Integer ; //全局FormCreate : i := 0 ;procedure TForm1.Button1Click(Sender: TObject); //打开 ,每次显示 10 条记录
    begin
      with ADOQuery1 do
      begin
        Close ;
        Sql.Text := 'select * from zhang_cpkkc where Id > ' + IntToStr(10*i)
                + '  and id < ' + IntToStr(10*i + 11) ;
        Open ;
        First ;
      end;
      i := i + 1 ;  if TButton(Sender) = Button1 then Button1.Enabled := False ;end;procedure TForm1.Button2Click(Sender: TObject);//下一页
    begin
      Button1Click(Button1) ;
    end;
      

  2.   

    Sql.Text := 'select * from zhang_cpkkc where Id > ' + IntToStr(10*i)
                + '  and id < ' + IntToStr(10*i + 11) ;
      

  3.   

    你可以建立几个翻页的按钮(最前,前页,后页,末页),设置一个自增变量来标志每页的数目,同时也要有一个记录的索引值,在显示完本页之后判断一下sql语句是否执行到了数据库中的最后一条,借此来判断翻页按钮是否可用。我就是通过这种方式实现的。
      

  4.   

    有自增加id的话,用楼上他们的方法是可以的,但如果没有可以这样实现:
    select top 每页显示数目 字段名 from 表名 where 字段名 not in(select top 每页显示数目*页数 from 表名 group by 字段名) group by 字段名
      

  5.   


    select top 500 from ……不是很清楚,学习
      

  6.   

    select top 每页显示数目 字段名 from 表名 where 字段名 not in(select top 每页显示数目*页数 from 表名 group by 字段名) group by 字段名
    上面這個方法還不錯。