asp.net+oracle自己写的oracle分页语句(repeater+aspnetpage---配合DbHelperOra)

 

  /// <summary>
        /// 根据条件分页查询结果
        /// </summary>
        /// <param name="sqlwhere">查询条件</param>
        /// <param name="page">第几页</param>
        /// <param name="pagesize">每页个数</param>
        /// <returns>结果集</returns>
        public static DataSet GetDataSetBySqlWhere(string sqlwhere, int page, int pagesize, string tablename)
        {

            string strSql = "SELECT * FROM (SELECT A.*, ROWNUM RN FROM (SELECT * FROM " + tablename;
            if (sqlwhere != "")
                strSql += " where " + sqlwhere;
            strSql += ") A WHERE ROWNUM <= " + pagesize * page + " )WHERE RN >= " + ((page - 1) * pagesize + 1);

            return DbHelperOra.Query(strSql.ToString());
        }
        /// <summary>
        /// 根据条件查询总个数
        /// </summary>
        /// <param name="sqlwhere">条件</param>
        /// <returns>总个数</returns>
        public static int GetCountBySqlWhere(string sqlwhere, string tablename)
        {
            string strSql = "select count(*) from " + tablename;
            if (sqlwhere != "")
                strSql += " where " + sqlwhere;
            object obj = DbHelperOra.GetSingle(strSql);
            if (obj != null)
                return Convert.ToInt32(obj);
            else
                return 0;

        }

你可能感兴趣的:(asp.net)