科技行者

行者学院 转型私董会 科技行者专题报道 网红大战科技行者

知识库

知识库 安全导航

至顶网软件频道快马加鞭 为Ado.net加速

快马加鞭 为Ado.net加速

  • 扫一扫
    分享文章到微信

  • 扫一扫
    关注官方公众号
    至顶头条

   当然首先是使用链接池了~~ 连接池 Connection Timeout--尝试连接数据存储区时的等待时间默认是15秒 Min Pool Size-连接池的最小容量 Max Pool Size-连接池最大容量默认是100

作者:中国IT实验室 来源:中国IT实验室 2007年10月1日

关键字: ADO 编程

  • 评论
  • 分享微博
  • 分享邮件

在本页阅读全文(共2页)

      当然首先是使用链接池了~~
  连接池
  Connection Timeout--尝试连接数据存储区时的等待时间默认是15秒
  Min Pool Size-连接池的最小容量
  Max Pool Size-连接池最大容量默认是100
  Pooling 默认是true则请求从连接池返回一个新的连接,没有泽创建
  
  Connection Reset表示在从连接池中删除数据库连接时,将会重置该连接,默认是true,如果设置成false则在创建连接时往返服务器的次数会更少但是不更新连接状态
  
  如果出了毛病就~~SqlConnection.ClearAllPools();//清除连接池
  ------然后是重头戏~~自然是使用异步咯
  1首先在连接字符串中设置一个 async=true
  -------理论就这么多了~~看段代码爽爽把 
   
  31041条纪录4秒 
  
  using System;
  using System.Data;
  using System.Configuration;
  using System.Collections;
  using System.Web;
  using System.Web.Security;
  using System.Web.UI;
  using System.Web.UI.WebControls;
  using System.Web.UI.WebControls.WebParts;
  using System.Web.UI.HtmlControls;
  using System.Data.SqlClient;
  public partial class Default5 : System.Web.UI.Page
  {
   protected void Page_Load(object sender, EventArgs e)
   {
  
  
   }
   protected void Button1_Click(object sender, EventArgs e)
   {
   DateTime old = DateTime.Now;
  
   SqlConnection DbCon;
   SqlCommand Command = new SqlCommand();
   SqlDataReader OrdersReader;
   IAsyncResult AsyncResult;//异步
  
  
   DbCon = new SqlConnection();
   DbCon.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionStringInfo"].ConnectionString;
   Command.Connection = DbCon;
  
  
   Command.CommandText = "Select";
   Command.CommandType = CommandType.StoredProcedure;
   Command.Connection = DbCon;
  
   try
   {
   DbCon.Open();
   AsyncResult = Command.BeginExecuteReader();
   while (!AsyncResult.IsCompleted)//获取异步操作是否已完成的指示。
   {
   //由于异步操作必须阻止线程秒钟
   System.Threading.Thread.Sleep(10);
  
   }
   OrdersReader = Command.EndExecuteReader(AsyncResult);
   GridView1.DataSource = OrdersReader;
   GridView1.DataBind();
   }
   catch (System.Exception)
   {
  
   }
   TimeSpan not=DateTime.Now-old;
   Label1.Text = not.Seconds.ToString();
   }
  } 

查看本文来源

    • 评论
    • 分享微博
    • 分享邮件
    邮件订阅

    如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。

    重磅专题
    往期文章
    最新文章