zoukankan      html  css  js  c++  java
  • 通过sql 实现简单分页(not in)

     /// <summary>
        /// 分页查询的sql语句
        /// </summary>
        /// <param name="attributes">要查询的字段(两端可以没有空格)</param>
        /// <param name="pageSize">每页要显示的行数</param>
        /// <param name="pageIndex">当前页索引</param>
        /// <param name="orderBy">依据那个字段排序(两端可以没有空格)</param>
        /// <param name="aod">升序(asc)还是降序(desc)(两端可以没有空格)</param>
        /// <param name="where">附加的条件(一定要有where关键字,两端可以没有空格)</param>
        /// <returns></returns>
        public static string SelectByPaging(int currentPageIndex, string field, int pageSize, string strWhere, string orderByWho, string orderDirection)
        {
            string ids = string.Format("SELECT TOP({0}*{1}) id FROM Base_Knowledge {2} ORDER BY {3} {4}", currentPageIndex, pageSize, strWhere, orderByWho, orderDirection);
            string whereLess = null;
            if (!string.IsNullOrEmpty(strWhere))
            {
                int whereIndex = strWhere.ToLower().IndexOf("where");
                whereLess = "AND" + strWhere.Substring(whereIndex + 5);
            }
            return string.Format(@"SELECT TOP {0} {1} FROM Base_Knowledge WHERE id NOT IN({2}) {3} ORDER BY {4} {5}",
            pageSize, field, ids, whereLess, orderByWho, orderDirection);
        }
    View Code
  • 相关阅读:
    PHP里文件的查找方式及写法
    上传文件
    用ajax对数据进行查看人员信息
    ajax实现分页
    jquery做个日期选择适用于手机端
    PHP用ajia代码写三级联动下拉
    JSON数据的定义
    jquery做一些小的特效
    对jquery操作复选框
    使用 LUT 模拟光照
  • 原文地址:https://www.cnblogs.com/zoumin123/p/6387425.html
Copyright © 2011-2022 走看看