Hi, I have a webform application, when I access the website, things works fine. but when multiple people access the site, it gives me a message that I have exceeded the connection pooling .
I revised my code accessing the database with the folling one. Still I am having same problem. Any idea how to prevent exceeling connection pool .
thanks for your support
- public static string conStr = WebConfigurationManager.ConnectionStrings["conStrKfmc"].ConnectionString;
- public SqlConnection con = new SqlConnection(WebConfigurationManager.ConnectionStrings["conStrKfmc"].ConnectionString);
- public DataSet getDataSetPassSql(string mySql)
- {
- DataSet ds;
- using (SqlConnection cn = new SqlConnection(conStr))
- {
- using (SqlCommand cmd = new SqlCommand(mySql, cn))
- {
- SqlDataAdapter da = new SqlDataAdapter(cmd);
- ds = new DataSet();
- using (cn)
- {
- cn.Open();
- da.Fill(ds);
- return ds;
- }
- }
- }
- }
- public int InsertUpdateDelete(string mySql, Dictionary myPara)
- {
- int rtn = 0;
- using (SqlCommand cmd = new SqlCommand(mySql, con))
- {
- cmd.CommandType = CommandType.Text;
- foreach (KeyValuePair p in myPara)
- {
- cmd.Parameters.AddWithValue(p.Key, p.Value);
- }
- using (con)
- {
- con.Open();
- rtn = cmd.ExecuteNonQuery();
- con.Close();
- }
- }
- return rtn;
- }
Thanks for your support