asp.net connection open and close
<p>Let say i have one asp.net application that is having some page that uses the connection continuesly.....</p>

<p>i have open the connection in class file in construscter ......</p>

<p>and i m accessing it using the object of the class....when ever database operation are required...</p>

<p>in start the application is running fine....but after some operation with database in datagrid(ex. sorting,paging,other).... it's gets slow...and again start working after some time....</p>

<p>do you guys have any solution or any suggession for that.....</p>

<p>i have used the connection in following way....</p>

<pre><code>public class student_operation
{
    public SqlConnection cn = new SqlConnection();
    public SqlCommand cmd = new SqlCommand();
    public SqlDataAdapter ad = new SqlDataAdapter();
    public DataSet rs = new DataSet();
    public DataSet rs1 = new DataSet();

    public student_operation()
    {
     //
     // TODO: Add constructor logic here
     //
        try
        {
            cn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["myconnection"].ConnectionString);
            cn.Open();
        }
        catch (Exception)
        {
            if (cn.State != ConnectionState.Closed)
            {
                cn.Close();
                cn.Open();
            }
        }
    }

}
</code></pre>
