ASP. NET exclusive operation method to prevent database processing failure caused by repeated user submissions

Source: Internet
Author: User

Today, I encountered a problem in executing a stored procedure. There is a stored procedure in the system, which takes a long time to execute. If a large number of users submit at the same time on the webpage, the transactions in the process will fail, resulting in processing errors.

The test modified the transaction level from read uncomitted to serializable. However, Errors still occur. The most likely cause is that the database resources are insufficient, cannot process multiple large-scale transactions at the same time. Since the database cannot solve the problemProgramStarting with, it is limited to full-order execution, so ...... Solve the problem. Post the method. Please advise.

Environment ASP. NET, database sqlserver 2005

CodeVery simple, as shown below


Function runprocedure ()

If (Application [ " Lockobj " ] = Null ) Application [ " Lockobj " ] = New Object ();
Lock (Application [ " Lockobj " ])
// Exec sp
// Long wait, about 10 seconds
// Other Processing



In this way, no matter how many users enter at the same time, only one user can run the stored procedure to prevent errors. The only problem is that the user will wait a little longer ......

Please advise.

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: 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.