当在数十万行数据中实现分页,我觉得只有直接用select * from table where id>500000 and id<500010
这种方法最快~~但是这就必须保证id列真的是一个步长为1的递增列,用标识符的话如果有删除数据就无法继续保持是按1递增了~~
大家谁有好的不麻烦的方法来解决~~?

解决方案 »

  1.   

    楼主可以参考一下asp的代码:
    在数据库中建立一个“序号”的字段用作记数就可以了,添加记录的时候利用
      rs.open "select max(序号) as xh from 病例",myconn,1,1
        if isnull(rs("xh")) then 
           xh=0
        else
           xh=rs("xh") 
        end if
        number=xh+1
      rs.close
    计算出序号,然后写入number删除记录的时候利用:
    rs.open "select * from 病例 order by id desc",myconn,1,1
    number=rs.recordcount
    do while not rs.eof
    newID=rs("id")&","&newID
    rs.movenext
    loop
    rs.close
    newID=left(newID,len(newID)-1)
    newIDS=split(newID,",")
    for i=0 to ubound(newIDS)
        cmstr="update 病例 set 序号="&i+1&" where id="&newIDS(i)
        myconn.execute(cmstr)
    next
    以保证序号的连续
    对于已有的数据可以利用
    rs.open "select * from 病例 order by id desc",myconn,1,1
    number=rs.recordcount
    do while not rs.eof
    newID=rs("id")&","&newID
    rs.movenext
    loop
    rs.close
    newID=left(newID,len(newID)-1)
    newIDS=split(newID,",")
    for i=0 to ubound(newIDS)
        cmstr="update 病例 set 序号="&i+1&" where id="&newIDS(i)
        myconn.execute(cmstr)
    进行一下序号的初始化。