C # million data query timeout problem

Source: Internet
Author: User

When filtering some information from millions of data in C #, there are often errors in program connection timeouts, many common errors, such as timeout expired. The timeout period elapsed prior to completion of the operation or the server and so on

This article describes several common solutions, purely personal opinion, welcome to shoot Bricks

①: Of course, the first step to check whether connection did not close the problem, the general novice will make this mistake, need to look carefully oh, this is not detailed said.

②: If you copy the SQL statement to Query Analyzer, and if the execution time is longer than 30 seconds, the following solution is generally used:

First analyze the cause of timeout, generally connection not closed or sqlconnection.connectiontimeout timeout, the other is sqlcommand.commandtimeout caused by, This method of SqlCommand is to get or set the wait time before terminating an attempt to execute a command and generating an error.

His default is 30 seconds, you can set to 0, it means no limit, but it is best not to set 0, otherwise it will wait indefinitely, only to the time of the Query Analyzer, to set this time can be

③: The execution time is not very long, but still the operation timeout, then there are many reasons, usually there are two kinds of, ASP. NET application has timed out, or the connection lifetime of the connection pool has passed, because the connection pool default value is 60 seconds, the two solutions are:

To resolve the application request timeout:

Add the following statement in Web. config:

<system.web>

</system.web>

Executiontimeout: Is the maximum time limit allowed to execute a request, in seconds
maxRequestLength: Indicates the maximum file upload size supported by ASP. This limitation can prevent .... We all know that. Oh

Resolve the problem with the program pool life cycle:

Modify in the database connection string: DATABASE=AA;UID=SA;PWD=SA; Pooling=true; MAX Pool size=1024; Min Pool size=1; Connection lifetime=60

As for the meaning basically from the English meaning of everyone will understand, hehe ... Of course, min Pool size=1 This setting has a lot of attention, if you want to study can look at the following article, hehe

Http://www.cnblogs.com/ZHUYIN/archive/2011/11/02/2232578.html

C # million data query timeout problem

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.