How can I raise a timeout exception in the database?

I need to test some ASP.NET code that handles timeout exceptions from an MS-SQL database call.

I can reduce my CommandTimeout parameter in the connection, however this can lead to errors before my code.

Is there an easy way to force the database to timeout 'on cue'?

+3
source share
8 answers

What you are looking for is the WAITFOR command , the database timeout in the queue whenever you want.

+10
source

Start the transaction in the SQL window of the management studio, update the table and do not commit it:

BEGIN TRAN
UPDATE table SET ...

This will block the attempt of any website to read this table.

+3

, , try, ?

+1

, ... , , !

0

Ive , Ethernet- lol...

0

, (sc stop "MSSQL $SQLEXPRESS" - ).

0

, mock, .

-.

0

write down a procedure or request that takes more than 30 seconds to execute and call it from asp.net code.

-1
source

Source: https://habr.com/ru/post/1711639/


All Articles