花边管理软件官方网站

让每个页面的生命周期过程只产生一个Connection连接

让每个页面的生命周期过程只产生一个Connection连接
页面基类代码如下:

public partial class BasePage : System.Web.UI.Page
{
    private SqlConnection _SqlConn;

    public  SqlConnection SqlConn
    {
        get
        {
            if (this._SqlConn == null)
            {
                this._SqlConn = new SqlConnection("connectionString");
                this._SqlConn.Open();                
            }
           return this._SqlConn;
        }       
    }

   

    public override void Dispose()
    {
        if (this.SqlConn.State != ConnectionState.Closed)
        {
            this.SqlConn.Close();
        }
        this.SqlConn.Dispose();
        base.Dispose();
    }
}

posted @ 2008-06-01 20:44  花边软件,花边管理软件,服装(鞋)管理软件  Views(651)  Comments(4Edit  收藏  举报
花边管理软件官方网站