asp.net connection open and close -


Assume that I have an asp.net application that continues to release some pages that use the connection .... .

I have opened the connection in the class file in the constructer ......

and it accesses it using the object of the class .... When the database operation is needed .. .

The application is running fine initially ... but after some operation of the database in DataGrid (pre-sorting, paging, other) .... it gets slows down ... and then working After some time ....

Do you have any solutions or suggestions for this ...

I have used the connection in the following ways. ...

  public class student_operation {public SqlConnection cn = new SqlConnection (); Public SQL Commands CMD = New SQL Commands (); Public SqlDataAdapter Ad = New SqlDataAdapter (); Public Dataset RS = New Dataset (); Public dataset rs1 = new dataset (); Public student_operation () {// // TODO: Try add constructor logic here // try {cn = new SqlConnection (System.Configuration.ConfigurationManager.ConnectionStrings ["myconnection"]. ConnectionString); Cn.Open (); } Hold (exception) {if (cn.State! = ConnectionState.Closed) {cn.Close (); Cn.Open (); }}}}}  

Make sure you are opening up and close your connection Are there. Do not worry about connection "pooling" Net will handle it automatically for you. Just open the connection, do your work and turn off the connection (even if it's in the stable part).


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

jquery - SimpleModal Confirm fails to submit form -

php - Multiple Select with Explode: only returns the word "Array" -