MSSQL timeout has reached

Source: Internet
Author: User

Sqlconnection con = new sqlconnection ("Server =.; database = mydb; uid = sa; Pwd = password ;")
Changed:
Sqlconnection con = new sqlconnection ("Server =.; database = mydb; uid = sa; Pwd = password; Connect timeout = 500 ")
It seems ineffective. If it is still running for 30 seconds, a timeout is reported!
Suddenly it seems that you can connect to the databaseCodeIndicates that the con attribute has a connectiontimeout,
Sqlconnection con = new sqlconnection ("Server =.; database = mydb; uid = sa; Pwd = ;");
Con. connectiontimeout = 180; // an error is reported. The connectiontimeout attribute is read-only!
The attempt failed, and then looked at the command object property, and found that it also has a similar property! Commandtimeout settings:
Sqlcommand cmd = new sqlcommand ();
Cmd. commandtimeout = 180;
Run again to solve the problem. The time set here is 180 seconds, that is, three minutes! You can set it as needed. If it is too long, you can also set it to 0. When this attribute is set to 0, there is no time limit. This attribute value should be used with caution.

 

You also need to set the time limit for running HTTP requests in the web. config configuration file.
<System. Web>
<Httpruntime maxrequestlength = "102400" executiontimeout = "720"/>
</System. Web>
The value is set to 720 seconds. The preceding maxrequestlength attribute is generally used to limit the size of uploaded files! The default value is generally 4096 KB (4 MB ).

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.