能不能分页读取?

解决方案 »

  1.   

    找找自定义分页的文章,孟子的网站有http://dotnet.aspx.cc/
      

  2.   

    http://dotnet.aspx.cc/ShowDetail.aspx?id=108B1516-53CE-4357-B061-17295AF9689F
      

  3.   

    自己写分页select top 页面记录条数 * from 表 where 记录id>(页数-1)*页面记录条数
      

  4.   

    用存储过程,只取回一页的数据!!TbJoin为选择的表ALTER PROCEDURE TbJoin_Select_list
    @pagesize int,
    @pageindex intASset nocount on
    begin
    declare @indextable table(id int identity(1,1),nid int)
    declare @PageLowerBound int
    declare @PageUpperBound int
    set @PageLowerBound=(@pageindex-1)*@pagesize
    set @PageUpperBound=@PageLowerBound+@pagesize
    set rowcount @PageUpperBound
    insert into @indextable(nid) select ID from TbJoin ORDER BY ID DESC
          
    SELECT TbJoin.ID,TbJoin.uid, TbJoin.cal      
    FROM @indextable t, TbJoin where  TbJoin.id =t.nid
    and t.id between @PageLowerBound and @PageUpperBound order by t.id  end
    set nocount off
      

  5.   

    回复人: xxuu503(公司不让上网!5555555555!) ( ) 信誉:100  2005-01-21 09:05:00  得分: 0  
     
     
       自己写分页select top 页面记录条数 * from 表 where 记录id>(页数-1)*页面记录条数 order by 记录id
    刚才我忘掉orderby了,呵呵
      

  6.   

    create proc GetAuthors
    @Author_Last_Name as varchar(100) = null,
    @StartRow as int = null,
    @StopRow as int = null
    AS---- 建立有标识符列的table变量
    declare @t_table table
    (
    [rownum] [int] IDENTITY (1, 1) Primary key NOT NULL ,
    [Author_Last_Name] [varchar] (40) ,
    [Author_First_Name] [varchar] (20) ,
    [phone] [char] (12) ,
    [address] [varchar] (40) ,
    [city] [varchar] (20) ,
    [state] [char] (2) ,
    [zip] [char] (5)
    )---- 在返回指定的@StopRow行数之后停止处理查询
    Set RowCount @StopRow---- 插入到table变量中
    insert @t_table
    (
    [Author_Last_Name],[Author_First_Name],[phone],[address],[city],[state],[zip]
    )
    SELECT [Author_Last_Name],[Author_First_Name],[phone],[address],[city],[state],[zip]FROM authors
    WHERE Author_Last_Name like '%' + @Author_Last_Name + '%'
    ORDER BY Author_Last_Name---- 返回到正确的结果
    SELECT * FROM @t_table WHERE rownum >= @StartRow
    ORDER BY rownumGO