Prevent concurrent execution of SQL Server stored procedure with ado.net in Asp.net

孤街浪徒 提交于 2019-12-08 16:20:37

Execute the stored procedure with ado.net transaction by setting isolation level to Serializable

Yes you can you can use the Serializable isolation level with your ado.net transaction. It is the highest isolation level and it relies on pessimistic concurrency control & guarantees consistency by assuming that two transactions may try to update the same data and uses locks to ensure that they do not. One transaction must wait for the other to complete and they can deadlock.

Use sp_getapplock inside stored procedure and release at the end

Yes you can use SQL Server application locks sp_getapplock. You will have to release the lock with sp_releaseapplock

Another option is to use Global Temporary Tables.

I would recommend utilizing a queuing system in the middle tier of your architecture, between ASP.NET and your database. That way requests recieved and processed in order. You can then configure the system to only process one request at a time,

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!