locked
Connection timeout being ignored RRS feed

  • Question

  • User882043084 posted

    Hi all,

    Have a query that takes approx 30 seconds to execute when run from sql server management studio (sql2005), however when

    I execute this query from a .net page using enterprise libray it times out after approx one minute.  The connection timeout on

    the sql connection string is 600 seconds.

    Does anyone know how I can set a timeout for this?

    The code below shows the C# code

    Regards

    Dave

     

    public IEnumerable<CustomerList> GetCustomerList(CustomerEntity ce)
            {
                ParameterMapper pm = new ParameterMapper(new List<String>() 
                { 
                    "@CustomerID", "@FirstName", "@LastName", "@Organisation", 
                    "@Address", "@CountryCode", "@PostCode", "@InvoiceNumber", "@CompanyCode" 
                });
    
                DataAccessor<CustomerList> customerAccessor = this.db.CreateSprocAccessor(
                    "usp_CustomerSearch",
                    pm,
                    MapBuilder<CustomerList>
                        .MapAllProperties()
                        .Map(x => x.ReformattedRefNo).ToColumn("ReformattedRefNo")
                        .Map(x => x.ReformattedAddress).ToColumn("ReformattedAddress")
                        .Map(x => x.CountryCode).ToColumn("COUNTRY_CODE")
                        .Build());
                try
                {
                    return customerAccessor.Execute(
                        ce.CustomerID, 
                        ce.FirstName, 
                        ce.LastName, 
                        ce.Organisation,
                        ce.FullAddress, 
                        ce.CountryCode, 
                        ce.PostCode,
                        ce.InvoiceNumber, 
                        ce.CompanyCode)
                        .ToList();
                }
                catch (SqlException sqlEx)
                {
                    // Log this
                    throw sqlEx;
                }
            }
    Thursday, March 3, 2011 5:25 AM

Answers

  • User-718146471 posted

    Take a look at this: http://forums.asp.net/t/903456.aspx/6/10

    "I would say that setting Connection timeout in web.config and  CommandTimeout of the SqlCommand object are right points but one more thing should be set beside that - this is the executionTimout of the requiest. If the execution timout is smaller than the connection timout you will not be able to get the response incuding the results. So set the execution timeout this way:

     

    <httpRuntime executionTimeout="36000" maxRequestLength="4096" useFullyQualifiedRedirectUrl="false" minFreeThreads="8" minLocalRequestFreeThreads="4" appRequestQueueLimit="100" />

    The timeout is defined in seconds so set it appropriate for you.The httpRuntime element is located in system.web."

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, March 3, 2011 9:12 AM

All replies

  • User-718146471 posted

    Never mind, didn't realize you already had a connection timeout set. Does your debugger give you any messages?

    Thursday, March 3, 2011 9:07 AM
  • User-718146471 posted

    Take a look at this: http://forums.asp.net/t/903456.aspx/6/10

    "I would say that setting Connection timeout in web.config and  CommandTimeout of the SqlCommand object are right points but one more thing should be set beside that - this is the executionTimout of the requiest. If the execution timout is smaller than the connection timout you will not be able to get the response incuding the results. So set the execution timeout this way:

     

    <httpRuntime executionTimeout="36000" maxRequestLength="4096" useFullyQualifiedRedirectUrl="false" minFreeThreads="8" minLocalRequestFreeThreads="4" appRequestQueueLimit="100" />

    The timeout is defined in seconds so set it appropriate for you.The httpRuntime element is located in system.web."

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, March 3, 2011 9:12 AM