数据库有一个字段是用来标志分页的记录,例如数据库中有下面的记录,当显示数据库
时出现所有标志字段记录为A的记录,当按下一页时出现所有标志记录为B的记录,再按上一页又出现标志字段记录为C的记录,按第一页出现标志字段记录为A记录,按最后一页出现标志字段记录为C的记录,就相当于ASP的翻页程序标志         用户         性别
---------- ---------- ---- ---
A           张颖      G
B           王伟      B
C           郝英      G
C           赵云      B
A           李健      G
B           萧小      B
C           李健      B

解决方案 »

  1.   

    呵呵。用sql语句简单啊。就是选择 
    select * from 数据表 where 标志=A
         就是标志为A的记录了。
    在该页的create事件中写。
      

  2.   

    在窗体上放个listview,两个button,一个label,一个adoquery,一个adoconnection
    然后用adoconnection建立一个连接
    procedure TForm1.Page_Count;
    var
      i:integer;
      ListItem:TListItem;
    begin
      ListView1.Clear;
      with AdoQuery1 do
      begin
        Connection := AdoConnection1;
        sql.Clear;
        sql.Add('select a,b from table');
        open;
        if Page = 0 then Page := 1;
        if Page > RecordSet.RecordCount then page := RecordSet.RecordCount;
        Recordset.PageSize := 10;  //每页十行
        RecordSet.AbsolutePage := Page;
        for i:= 1 to Recordset.PageSize do
        begin
          ListItem := ListView1.Items.Add;
          ListItem.SubItems.Add(RecordSet.Fields.Item[0].value);
          ListItem.SubItems.Add(RecordSet.Fields.Item[1].Value);
          Next;
          if RecordSet.EOF then exit;
        end;
      end;
    end;procedure TForm1.Button1Click(Sender: TObject);
    begin
      Page := Page+1;
      Page_Count;
      Label1.Caption := IntToStr(Page);
    end;procedure TForm1.Button2Click(Sender: TObject);
    begin
        Page := Page -1;
        Page_Count;
        Label1.Caption := IntToStr(Page);
    end;
      

  3.   

    类似上
    可用select distinct 标志 from……把返回的记录集加到一个list类的控件,如listbox,listview等等
    然后就可以作按钮第一个,前一个,下一个,最后一个
    实际上就是list的第一个,前一个,下一个,最后一个
    然后就可以用SQL select……where 标志=当前listitem的值
    就搞定
      

  4.   

    用SQL的话:
    SQL SERVER SELECT TOP N FORM TABLE 
    ORACLE(select * from table where rownum<n*m) minus
    (select * from table where rownum<n*(m-1))    --n是你每页的记录数,M是当前的页数
      

  5.   

    我的思路:先用select 标志 from 用户表 group by 标志,进行分组把分组的记录读到一个动态数组中,再用select * from 用户表 where 标志='''+a[0]+'''进行查找(就相当于查找),上一页和下一页就是把动态数组的下标加一减一,各位大侠认为呢???
    var
      Form1: TForm1;
      a:array of string;
      x,i:integer;procedure TForm1.FormCreate(Sender: TObject);
    begin
      with adoquery1 do
        begin
           close;
           sql.Clear;
           sql.Add('select 标志 from 用户表 group by 标志');
           open;
        end;
      x:=adoquery1.RecordCount;
      SetLength(a, x);
      for i:=0 to x-1 do
        begin
          a[i]:=adoquery1.Fields[0].Value;
          adoquery1.Next;
        end;
      with adoquery1 do
        begin
           close;
           sql.Clear;
           sql.Add('select * from 用户表 where 标志='''+a[0]+'''');
           open;
        end;
    end;
      

  6.   

    pcwak (书剑狂生[MS MVP])   你的问法.根本就是误导我们.!!!
    这根本算不上是分页的功能.  只是一个按类显示.而且你没有告诉我们你的标志都有哪些怎么可能回答呢?  是不是a~z 呢?
    如果是. 则可以这样.设个标识变量.
    当用户按下页时判断标识是否已经到ascii 90.
    如果没有则标识ascii加1.然后sql查找对应标识的记录.
    上页时一样判断是否小于65.  没有则同样执行查询.