Sql 分页
发布日期:2021-09-03 20:58:06 浏览次数:4 分类:技术文章

本文共 888 字,大约阅读时间需要 2 分钟。

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];

转载于:https://www.cnblogs.com/xsmhero/archive/2012/07/02/2572656.html

转载地址:https://blog.csdn.net/weixin_34195142/article/details/92851424 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:2019-05-31 Java学习日记之IO(其他流)&Properties
下一篇:linux下性能分析命令[总结]

发表评论

最新留言

能坚持,总会有不一样的收获!
[***.172.111.71]2022年05月22日 09时53分22秒