Sunday, February 26, 2012

Error Code if Row is locked

Hallo,
if a row is locked in SQLExpress and an other user want to update this row,
SQLExpress waits until timeout. And than I get the errormessage "timeout".

What I need is an immediately errormessage "row is locked" !

So that the user dont need to wait if the row is locked
and I need the correct errormessage so that I can check
if there is a databaseproblem or only the row locked
because an other user is editing the same rows.

Thx Wolfgang
(please excuse my english)

hi,

SQL Server does not provide this feature as this should be managed on the client side of the application and not server side on SQL Server...

you can thus set an appropriate timeout on the ado/ado.net command you are using, and then take the required decision once the command result in an exception..

but you have to fine tune your timeout, depending on SQL Server load, bandwidth, network trafic, ..

regards

|||

Thank you for your help!

I need a small timeout if the Updatecommand "meets" locked rows.
I do not want to reduce the timeout for the SqlCommand itself.

The solution i have found is to use the keyword NOWAIT in the SQL-Statement.

UPDATE table WITH (NOWAIT) SET ......

I think this works okay, but I have not found something to set timeout for locks to 1 sec
and timeout for SQLCommand to 15 sec.

Thany you for your help.
Wolfgang

No comments:

Post a Comment