高分求“支持查询”的分页代码(access)
我原来有个分页代码,但是不支持查询,能否改一下支持查询。源代码如下OleDbConnection conn = new OleDbConnection();
        conn.ConnectionString = "Provider = Microsoft.Jet.OleDb.4.0;" + "Data Source =" + Server.MapPath("App_Data/**.mdb");
        string strSel = "select * from book";
        OleDbCommand selcom = new OleDbCommand(strSel, conn);
        OleDbDataAdapter da = new OleDbDataAdapter();
        conn.Open();
            
        da.SelectCommand = selcom;
        DataSet ds = new DataSet();
        da.Fill(ds, "book");
        DataTable dt = ds.Tables["book"];
     
        conn.Close();
        ArticleList.DataSource = dt;
        ArticleList.DataBind();
        int CurPage;
        if (Request.QueryString["Page"] != null)
            CurPage = Convert.ToInt32(Request.QueryString["Page"]);
        else
            CurPage = 1;
        PagedDataSource ps = new PagedDataSource();
        ps.DataSource = ds.Tables[0].DefaultView;
        ps.AllowPaging = true;
        ps.PageSize = 20;//每页数据的数量
        this.onepage.Text = ps.PageSize.ToString();
        this.allmsg.Text = ps.DataSourceCount.ToString();
        ps.CurrentPageIndex = CurPage - 1;
        this.allpage.Text = ps.PageCount.ToString();
        this.allpage1.Text = ps.PageCount.ToString();
        this.nowpage.Text = CurPage.ToString();
        this.ArticleList.DataSource = ps;
        this.ArticleList.DataBind();
            Firstpage.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=1";
            Lastpage.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + ps.PageCount.ToString();
       
        if (!ps.IsFirstPage)
            prepage.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage - 1);
        if (!ps.IsLastPage)
            nextpage.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(CurPage + 1);
       

解决方案 »

  1.   

    string strSel = "select * from book where column like '***'";
      

  2.   

    string where="";
    string strSel = "select * from book where 1=1 "+where;
      

  3.   

    Select * from a where name like '*b*'
    日期#
      

  4.   

    是这样的,我后面加了where 后,第一次读数据能读出来,但是我点击下一页,末页,就什么都没有了。
      

  5.   

    是这样的,我后面加了where 后,第一次读数据能读出来,但是我点击下一页,末页,就什么都没有了。 
      

  6.   

    直接用aspnetpager吧,网上搜索一下