An issue with ASP. NET LINQ SQL execution timeout

Source: Internet
Author: User

Recently in the process of writing an air material price. Because the execution of the statement complex, the amount of data is large, easy to cause timeouts.

Look at the hint should be the execution of SQL time out, I used LINQ in the program.

It takes about 40 seconds to actually observe the SQL statement alone.

Check the information

Sqlcommand.commandtimeout
Gets or sets the wait time before terminating an attempt to execute a command and generating an error.
The time, in seconds, to wait for the command to execute. The default is 30 seconds.

The actual observation of the time also found that the general prompt error is in the execution of the statement 30 seconds.

To resolve this problem, you can customize the time in the program to execute the statement timeout.

The traditional use of ADO

CommandTimeout = 180

LINQ can use

using (MainContext db = new MainContext()){ db.CommandTimeout = 3 * 60; // 3 Mins}


要考虑优化SQL语句,改成存储过程之类得了,看来。

An issue with ASP. NET LINQ SQL execution timeout

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.