zoukankan      html  css  js  c++  java
  • Sql 分页

    string fids = "";
                for (int i = 0; i < fieldIDs.Length; i++)
                {
                    if (!fieldIDs[i].Equals("")) { fids += "," + fieldIDs[i]; }
                }
                fids = (fids.Length > 1 ? fids.Substring(1) : "*");

    string cmdText = @"SELECT ROW_NUMBER() OVER(ORDER BY UPLOADDT DESC) AS ROW_INDEX,
                                       " + fids + " FROM SURVEYINFO(NOLOCK)  WHERE 1=1";
                if (!string.IsNullOrEmpty(where_clause) && where_clause != "")
                {
                    cmdText += " and " + where_clause;
                }
                if (!string.IsNullOrEmpty(orderby_clause) && orderby_clause != "")
                {
                    cmdText += " " + orderby_clause;
                }
               
                int iStartPage = (iPageIndex * iPageSize) + 1;
                int iEndPage = (iPageIndex * iPageSize) + iPageSize;
                cmdText = string.Format(@"SELECT * FROM ({0}) T
                                    WHERE T.ROW_INDEX BETWEEN {1} AND {2}", cmdText, iStartPage, iEndPage);

    return SqlHelper.ExecuteDataset(ConnectionString, CommandType.Text, cmdText).Tables[0];

  • 相关阅读:
    3Sum
    Longest Common Prefix
    Integer to Roman
    Roman to Integer
    Container With Most Water
    String to Integer (atoi)
    Regular Expression Matching
    codeforces-873C. Strange Game On Matrix[模拟]
    hdu-5927 Auxiliary Set
    Codeforces-869 C. The Intriguing Obsession [组合数学]
  • 原文地址:https://www.cnblogs.com/xsmhero/p/2572656.html
Copyright © 2011-2022 走看看