Solution to time-out problems in C # million data query

Source: Internet
Author: User

This article explains in detail the solution of the time-out problem of C # million data query, and share it for everyone's reference. Here's how:

Many times when we use C # to filter some information from millions of data, there are often errors in program connection timeouts, and there are many common errors, such as:


Timeout expired. The timeout period elapsed prior to completion of the operation or the server

Wait a minute

This article describes several common solutions, which are interesting to improve and improve.

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

②. If you copy the SQL statement into Query Analyzer, 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.

of his

The 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>

Executiontimeout: Is the maximum time limit allowed to execute a request, in seconds

maxRequestLength: Indicates the maximum file upload size supported by ASP. This limit can be prevented. We all know that.

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, the min Pool size=1 This setting has a lot to pay attention to.

I hope this article is helpful to everyone's C # programming.

In addition to the Declaration,Running GuestArticles are original, reproduced please link to the form of the address of this article
Solution to time-out problems in C # million data query

This address: http://www.paobuke.com/develop/c-develop/pbk23552.html






Related content C # inverter and covariance C # implementation file upload and file download function instance code C # method of fetching a tag link and innerhtml based on regular expression C # WinForm Click Generate QR Code instance
C # is implemented with existing. NET event Bridging simple instance C # methods for downloading network files at speed limit use C # to implement a web crawler C # Method of scaling using the matrix

Solution to time-out problems in C # million data query

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.