作者:动态网站…
来源:动态网站制作指南
热度:
2007-5-28 13:44:13
当然首先是使用链接池了~~ Connection Reset表示在从连接池中删除数据库连接时,将会重置该连接,默认是true,如果设置成false则在创建连接时往返服务器的次数会更少但是不更新连接状态 如果出了毛病就~~SqlConnection.ClearAllPools();//清除连接池 SqlConnection DbCon; try } }
连接池
Connection Timeout--尝试连接数据存储区时的等待时间默认是15秒
Min Pool Size-连接池的最小容量
Max Pool Size-连接池最大容量默认是100
Pooling 默认是true则请求从连接池返回一个新的连接,没有泽创建
------然后是重头戏~~自然是使用异步咯
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;
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;
{
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();
}
}
- -上面的只是小事伸手~~来个速度更快的
我来说两句:
推荐文章
相关文章