Click to See Complete Forum and Search --> : Begin/commit Transaction???


Will192
09-10-2003, 08:40 AM
I am running Windows 2000 Server & ASP. My database is SQL Server 2000. My pages are coded in a mix of VBScript, Javascript, ASP and obviously HTML.

I am looking for a way to rollback unfinished transactions. I have a group of transactions that run when a user submits and one of my forms. If a user closes the window before the transactions complete, I want to roll back all of the transactions.

This has got to be a common occurance for web applications. I have setup BEGIN TRANSACTION and COMMIT TRANSACTION at the start and end of my groups of transactions.

Is this enough? I have tested and it seems fine. What kind of locking am I going to run into with this setup? What are the pros and cons of handling it this way?

Thanks in advance for any responses to this post.

Will192

Ribeyed
09-17-2003, 07:01 AM
Hi,
you should use ROLLBACK TRANSACTION.

rollback transaction throws away all changes since the most recent BEGIN TRANSACTION. You can supply a transaction name as either a constant or a variable, but SQL Server ignores this name. You can also roll back part of a transaction by supplying a savepoint name. If a transaction is a distributed transaction (one that affects databases on multiple servers), you can't roll back to a savepoint.



ROLLBACK TRANS[ACTION]
[transaction_name |
@name_variable |
savepoint_name |
@savepoint_variable ]
ROLLBACK [WORK]



Hope this helps.