程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> Access數據庫 >> Access數據庫入門 >> asp.net 和 access 聯合開發的分頁類

asp.net 和 access 聯合開發的分頁類

編輯:Access數據庫入門
  using System;
  using System.Collections.Generic;
  using System.Text;
  using System.Data;
  namespace pager
  {
  public class Pager
  {
  /// <summary>
  ///
  /// </summary>
  /// <param name="strWhere">條件</param>
  /// <param name="pagesize">每頁顯示條數</param>
  /// <param name="pageindex">第幾頁</param>
  /// <param name="orderCol">排序</param>
  /// <param name="TableName">表名</param>
  /// <returns></returns>
  public static string GetPager(string strWhere, int pagesize, int pageindex, string orderCol, string TableName)
  {
  if (pageindex == 1)
  {
  return "select top " + pagesize.ToString() + " * from " + TableName.ToString() + " order by " + orderCol.ToString() + " DESC";
  }
  else
  {
  StringBuilder strSql = new StringBuilder();
  strSql.AppendFormat("select top {0} * from {1} ", pagesize, TableName);
  strSql.AppendFormat(" where {1} not in (select top {0} id from {2} ", pagesize * (pageindex - 1), orderCol, TableName);
  if (strWhere.Trim() != "")
  {
  strSql.AppendFormat(" where {0} order by {1} DESC) and {0}", strWhere, orderCol);
  }
  else
  {
  strSql.AppendFormat(" order by {0} DESC) ", orderCol);
  }
  strSql.AppendFormat(" order by {0} DESC", orderCol);
  return strSql.ToString();
  }
  }
  }
  }
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved