简单实用的分页类(7)
来源:未知 责任编辑:责任编辑 发表时间:2015-09-16 20:04 点击:次
line-height: 26px;
border-right-style: none;
margin: 1px 2px;
padding-left: 6px;
padding-right: 6px;
border-top-style: none;
background: #f80;
color: #fff;
font-size: 12px;
border-left-style: none;
padding-top: 5px;
}
</style>
五、再加一个数据访问层的Select代码
public int GetTotalCount()
{
string sql = "SELECT count(*) FROM so_KeywordLog";
return (int)DbHelperSQL.GetSingle(sql);
}
public DataSet GetPagedData(int minrownum, int maxrownum)
{
string sql = "SELECT * from(SELECT *,(row_number() over(order by Id))-1 rownum FROM so_KeywordLog) t where rownum>=@minrownum and rownum<=@maxrownum";
SqlParameter[] parameters = { new SqlParameter("@minrownum", SqlDbType.Int, 4), new SqlParameter("@maxrownum", SqlDbType.Int, 4) };
parameters[0].Value = minrownum;
parameters[1].Value = maxrownum;
return DbHelperSQL.Query(sql, parameters);
}
六、相关分页Select语句(扩展)
1 存储过程
create PROCEDURE GetPageDataOutRowPageCount2
(
@PageIndex int = 1,--当前页数
@PageSize int = 10,--每页大小
@RowCount int output,--总行数(传出参数)
@PageCount int output--总页数(传出参数)
)
AS
begin
DECLARE @sql NVARCHAR(225),@sqlCount NVARCHAR(225)
select @RowCount =COUNT(SID),@PageCount=CEILING((COUNT(SID)+0.0)/@PageSize) FROM Students
SET @sql='SELECT TOP '+str(@PageSize) +' FROM Students where SID not in(select top '+str((@PageIndex-1)*@PageSize) +' SID from Students)'
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>