开发者

If I create a TransactionScope, is there a chance of it blocking the database if I stop it whilst debugging?

I'm just debugging this error which I have suddenly seem to have gotten when I'm writing a row to a table.

Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. The statement has been terminated.

Does it have something to do with transaction scopes? I was wondering if I create a transaction scope and I debug through and I literally stop the application in the middle of debugging before it's reached the end of the开发者_运维问答 trasnaction scope - is there a chance it'll block the database?

If so, how do I unblock it?

NOTE - This might help, right now, I'm having trouble inserting a row in tables but have accessing and updating existing rows

UPDATE - Well I reset the SQL Server service and it seems to have done the trick. Still, I'm curious to heard how it could've locked in the first place - I do not want some part of my code to be doing that and happening in production.


If opening a DB transaction would lock the entire database, that would be massively disappointing. Generally speaking, SQL Server locks on a per-row basis and then escalates these locks as neccessary (I'm simplifying matters here significantly).

Each transaction has a timeout it's given to complete. If this time elapses and you nether commit nor roll back, you'll get that "Timeout expired" exception.

As far as "unblocking" goes, you don't usually have to worry. Everything's unlocked as soon as you close the connection.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜