1. 程式人生 > >遞歸算法+sql三種分頁

遞歸算法+sql三種分頁

public ati names collect div response ber urn void

using Maticsoft.Common;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Maticsoft.Web.cest
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        Maticsoft.BLL.lhzExcSQL lhz 
= new BLL.lhzExcSQL(); protected void Page_Load(object sender, EventArgs e) { //Response.Write(Fun(4)); if (!IsPostBack) { Fun(30); } } //遞歸算法 1,1,2,3,5,8,13 求第n位數是多少? public int Fun(int n) {
if (n < 1) return 0; if (n == 1 || n == 2) return 1; else return Fun(n - 1) + Fun(n - 2); } //三種常見分頁 //DataTable dt = lhz.GetTalbe("select nid,ntitle from news order by nid OFFSET (5 * (1-1)) ROW FETCH NEXT 5 rows only"); //DataTable dt = lhz.GetTalbe("select top 5 nid,ntitle from news where nid not in (select top 0 nid from news order by nid) order by nid");
//DataTable dt = lhz.GetTalbe("select * from (select top 5 nid,ntitle,ROW_NUMBER() over(order by nid) r from news) tt where tt.r between 1 and 5"); } }

遞歸算法+sql三種分頁