locked
Timeout error using Database blocks RRS feed

  • Question

  • User-1885255629 posted

    System.InvalidOperationException: Timeout expired.  The timeout period elapsed prior to obtaining a connection from the pool.  This may have occurred because all pooled connections were in use and max pool size was reached

     

    ---Here is the code----- 

      {
                string connectionstring = ConfigurationManager.ConnectionStrings["CWGCartConnectionString"].ToString();
                SqlDataReader reader1 = null;
                SqlParameter[] parameterArray1 = new SqlParameter[1];
                parameterArray1[0] = new SqlParameter("@custID", SqlDbType.Int);
                parameterArray1[0].Value = custID;
                try
                {
                    reader1 = SqlHelper.ExecuteReader(connectionstring, CommandType.StoredProcedure, "x_stored_procedure", parameterArray1);
                }
               
                catch (SqlException exception1)
                {
                    string text1 = "Error Executing x_stored_procedure: \r\n";
                    foreach (SqlParameter parameter1 in parameterArray1)
                    {
                        object obj1 = text1;
                        text1 = string.Concat(new object[] { obj1, parameter1.ParameterName, "=", parameter1.Value, "\r\n" });
                    }
                    throw new Exception(text1, exception1);
                }
                return reader1;
            }

    Thursday, March 8, 2007 9:22 PM

All replies

  • User-1095120877 posted

    hi,

    you are using a bit wrong approach, why are you returning DataReader, it requires the connection to be open when you are returning the datareader in this case connection will be left open even if you are closing datareader as per what i think.

    i think you are using layered architecture ???

    what i suggest you is to use dataset instead of reader and try to run the code. make sure you close connection even though its not required .

    thanks,

    satish.

    Thursday, March 8, 2007 9:48 PM