问题描述如下: 我在客户端通过CLIENTDATASET来访问服务器端数据库 现在想在DBGRID里显示 实现分页显示的功能 请问该如何实现呢 数据库是ORACLE

解决方案 »

  1.   

    可用ClientDataSet.GetNextPacket實現分頁
      

  2.   

    可以 但是具体的方法是怎么样的呢 : wjc1000(小疙瘩) 谢谢
      

  3.   

    现学现卖:
    给每条数据设个ID值(int),然后排序,根据每页的个数(PageSize)及页号计算出FirstID号(pageSize*页号),然后取记录
    'Select Top ' + IntToStr(PageSize) + ' ID,Name,Age From uu987 Where ID<'+IntToStr(FirstID)+' Order By ID Desc';
    就是这么个思路
      

  4.   

    'Select Top ' + IntToStr(PageSize) + ' ID,Name,Age From uu987 Where ID<'+IntToStr(FirstID)+' Order By ID Desc';
    只能在sql和access里用
    oracle好像要用rownum
      

  5.   

    用 Anylib
    http://www.anylib.com
      

  6.   

    数据库 是ORACLE 啊各位大哥 SELECT 语句对其行不通 有clientdataset的方法吗
      

  7.   

    第一页
    adoq.sql.add('select top '+inttostr(per_page_count)+' * from table1 where id not in (select top '+inttostr(PrevPageVariant)+' id from table1)')
    PrevPageVariant:=0
    adoq.open;下一页
    adoq.sql.add('select top '+inttostr(per_page_count)+' * from table1 where id not in (select top '+inttostr(PrevPageVariant)+' id from table1)')
    inc(PrevPageVariant,1);
    adoq.open;上一页
    adoq.sql.add('select top '+inttostr(per_page_count)+' * from table1 where id not in (select top '+inttostr(PrevPageVariant)+' id from table1)')
    dec(PrevPageVariant,1);
    adoq.open;末页
    adoq.sql.add('select count(*) as 总数 from table1);
    adoq.open;
    PrevPageVariant:=trunc(adoq.fieldbyname('总数').asinteger/per_page_count);
    adoq.sql.add('select top '+inttostr(per_page_count)+' * from table1 where id not in (select top '+inttostr(PrevPageVariant)+' id from table1)')
    adoq.open;
      

  8.   

    cym830313(blue freezing point) 你那还是基于SELECT语句来做的啊 ORACLE根本不支持TOP关键词 各位大哥有没有CLIENTDATASET的方法啊
      

  9.   

    http://www.coderpub.com/Search.aspx?type=2&message=%b7%d6%d2%b3&auther=http://www.coderpub.com/View.aspx?fbId=5&Id=1671
      

  10.   

    CLIENTDATASET的我试了一下,不是很好
    他是这样显示的前20(我设置显示一次20条)
    前40
    前60
    …………
      

  11.   

    ADOConnection1  连接数据库
    ADOQuery1       执行查询      connection  为 ADOConnection1 
    DataSetProvider1得到adoquery1查询的数据  dataset为adoquery1
    ClientDataSet1  PacketRecords设为20   providername为DataSetProvider1   右键,fields editor 中添加,选择你要的数据项
    DataSource1     dataset为ClientDataSet1
    DBGrid1         DataSource为DataSource1
    把active设为true就可以了
      

  12.   

    wjc1000(小疙瘩)  我照你的方法做了一下 不知道是不是操作的问题 好象不行啊 还是全部显示出来了
      

  13.   

    wjc1000(小疙瘩)  谢谢你 现在有所进展了 可是 好象只能向下 而不能往上啊
      

  14.   

    我们经常要访问数据集的某一个中间部分,例如第10到第20条记录,Oracle中有一个很好语句来实现,那就是with。以下是使用的例子: with partdata as (select rownum rowno,t.* from  table1 t where t.id>200407160000) 
    select * from partdata where rowno between 10 and 20 当然还有别的方法,但我目前测试这种方法的速度最快。
      

  15.   

    1. 最好还是利用分析函数  row_number() over ( partition by col1 order by col2 )  比如想取出100-150条记录,按照tname排序  select tname,tabtype from (  select tname,tabtype,row_number() over ( order by tname ) rn from tab  )  where rn between 100 and 150;  2. 直接使用rownum 虚列  select tname,tabtype from (  select tname,tabtype,rownum rn from tab where rownum <= 150  )  where rn >= 100;  使用序列不能基于整个记录集合进行排序,如果指定了order by子句,排序的的是选出来的记录集的排序.
      

  16.   

    wjc1000(小疙瘩) 大哥我的QQ是25688474
      

  17.   

    wjc1000(小疙瘩) 大哥我的QQ是25688474 可以的话加我