Shishu Singh

Shishu Singh

  • NA
  • 69
  • 949

Regarding Connection pooling

Jan 19 2018 6:21 AM
Hi All,
Please guide me.
SqlConnection con = new SqlConnection();
con.ConnectionString = conn + "Connection Timeout=30;Connection Lifetime=0;Min Pool Size=0;Max Pool Size=1;Pooling=true;integrated security=true";
SqlCommand cmd = new SqlCommand("Storeprocedure", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Action", "Select");
con.Open();
SqlDataReader dr = cmd.ExecuteReader();
Grd1.DataSource = dr;
Grd1.DataBind();
con.Close();
In the above code i configure max pool size is 1 and every time i open and close the conection If i not closing the connection ,during reload binding grid again it wil reached out of the max pool size.
If i using open and close connection each time then the things becomes same that take more time consuming, what benefit of connection pooling.
Please guide me if i not closing the connection then how its beneficial and not reached out of the max pool size.
 
Thanks in advance 

Answers (2)