经典的c# 分页程序 20W 数据实测 0.875秒

C#分页查询优化:20万数据实测0.875秒
本文展示了如何使用C#进行高效的分页查询,实测在20万条数据中完成查询仅需0.875秒。代码实现包括设置连接字符串、定义查询条件、计算总页数、生成分页SQL语句,以及处理用户交互。通过调整SQL查询优化了分页性能。

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.HtmlControls;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Data;

using System.Data.SqlClient;

using System.Configuration;

 

public partial class product : System.Web.UI.Page

{

    public static readonly string strconn = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString;

    string tblName = "v_product";    //要查询表的表明

    string fldName = "id";       //条件 自动增张的

    // string orderStr = "asc";    //顺序 排序 如果是desc倒叙的话 需要改下

    int PageSize = 25;

  //  protected DateTime dt; //定义时间差变量

    protected void Page_Load(object sender, EventArgs e)

    {

 

       if (!Page.IsPostBack)

        {

            if (Session["username"] == null)

            {

 

                Response.Write("<script>window.open('login.aspx');</script>");

                Response.Write("<script>window.close();</script>");

            }

            else

            {

 

                //开始显示第一页

                //ShowDate(2);

                ShowDate(Convert.ToInt32(lblCurrentPage.Text));

            }

        }

 

    }

    protected override void OnPreInit(EventArgs e)

    {

      //  dt = D

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值