sqlserver 分页
/// <summary>
/// 分页
/// </summary>
/// <param name="pagesize">一页显示多少条记录</param>
/// <param name="pageindex">当前页</param>
/// <param name="table">表名</param>
/// <param name="wherestr">条件</param>
/// <param name="sortzd">排序字段</param>
/// <param name="sort">排序方式</param>
/// <returns></returns>
public DataTable zdypadding(int pagesize, int pageindex, string table, string wherestr, string sortzd, string sort)
{
int lindex = (pageindex - 1) * pagesize + 1;
sql = "select top " + pagesize + " * from " + table + " " + wherestr + " and " + sortzd + " <= (select min (" + sortzd + ") from (select top "+lindex+" "+sortzd+" from "+table+" "+wherestr+" order by "+sortzd+" "+sort+" ) as t ) order by "+sortzd+" "+sort+"";
dt = DBUtility.DbHelperSQL.Query(sql).Tables[0];
return dt;
}
/// 分页
/// </summary>
/// <param name="pagesize">一页显示多少条记录</param>
/// <param name="pageindex">当前页</param>
/// <param name="table">表名</param>
/// <param name="wherestr">条件</param>
/// <param name="sortzd">排序字段</param>
/// <param name="sort">排序方式</param>
/// <returns></returns>
public DataTable zdypadding(int pagesize, int pageindex, string table, string wherestr, string sortzd, string sort)
{
int lindex = (pageindex - 1) * pagesize + 1;
sql = "select top " + pagesize + " * from " + table + " " + wherestr + " and " + sortzd + " <= (select min (" + sortzd + ") from (select top "+lindex+" "+sortzd+" from "+table+" "+wherestr+" order by "+sortzd+" "+sort+" ) as t ) order by "+sortzd+" "+sort+"";
dt = DBUtility.DbHelperSQL.Query(sql).Tables[0];
return dt;
}