sqlServer通用分页
1 /// <summary> 2 /// 分页获取数据列表 3 /// </summary> 4 public DataSet GetList(int PageSize, int PageIndex, string strWhere) 5 { 6 StringBuilder strSql = new StringBuilder(); 7 strSql.Append("select count(userId) as AllRows from USERS where " + strWhere + " "); 8 strSql.Append("SELECT * FROM ( "); 9 strSql.Append("SELECT ROW_NUMBER() OVER(ORDER BY createTime) as ROWID, userId, userType, personId, account, password, isAdmin, enabled, loginIP, loginTime, loginTimes, lastLoginIP, lastLoginTime, remark, state, createUser, createTime, updateUser, updateTime FROM USERS "); 10 strSql.Append(" WHERE " + strWhere); 11 strSql.Append(") AS TMP_GAME "); 12 strSql.Append(" WHERE ROWID > " + (PageSize * (PageIndex - 1))); 13 strSql.Append(" AND ROWID <= " + (PageSize * (PageIndex - 1) + PageSize)); 14 return new DbHelperSQL().ExecuteQuery(strSql.ToString());