日期:2014-05-17  浏览次数:20375 次

求显示留言代码
SQL code

USE [guestbook]
GO
/****** Object:  StoredProcedure [dbo].[selectmessage]    Script Date: 08/27/2012 17:40:09 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER proc [dbo].[selectmessage]
 @pageSize int,
 @pageIndex int
as
declare @sql nvarchar(200)
if(@pageIndex<2)
begin
set @sql='select top '+convert(varchar(10),@pageSize)+' * from gbook'
end
else
begin
set @sql='select top '+convert(varchar(10),@pageSize)+' * from gbook where
id>(select max(id) from (
  select top '+convert(varchar(10),@pageSize*(@pageIndex-1))+' id from gbook order by id) a)order by id'
end
exec sp_executesql @sql




上面是存储过程代码,求用它写成适合大数据量分页查询的显示留言本的代码,开发环境:VS2010+SQLSERVER2008 ASP.NET(C#).显示留言本就可以了,其他的不用。

------解决方案--------------------
51aspx.com
------解决方案--------------------
http://download.csdn.net/detail/wwk0125/4496796 代码。
------解决方案--------------------
select * from (select rownumber() over(order by id asc) tNumber ,* from gbook)table1 where table1.tNumber>(@index-1)*@pageSize and table1.tNumber<=(@index*@pageSize)

把这个改改,放到你那个里面试试,我记得不是非常清楚了,应该是这样写的