点击这里给我发消息 点击这里给我发消息
首页 > 行业资讯 > Access>详细内容

asp.net 和 access 联合开发的分页类

添加时间:2010-6-22
    相关阅读: 开发
 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();
  }
  }
  }
  }
本文作者:
咨询热线:020-85648757 85648755 85648616 0755-27912581 客服:020-85648756 0755-27912581 业务传真:020-32579052
广州市网景网络科技有限公司 Copyright◎2003-2008 Veelink.com. All Rights Reserved.
广州商务地址:广东省广州市黄埔大道中203号(海景园区)海景花园C栋501室
= 深圳商务地址:深圳市宝源路华丰宝源大厦606
研发中心:广东广州市天河软件园海景园区 粤ICP备05103322号 工商注册