Board index » delphi » InTransaction dialog

InTransaction dialog


I need to check if a TDatabase.Transaction is already active.  So I need to
do a
"if DataBase1.InTransaction then.."

I want to have a dialog to pop up telling the user that another user is
currently updating the database.  My app should automatically check if the
ongoing transaction has terminated and if so, close the dialog automatically
and continue program execution, also it should have an Abort button giving
the user the opportunity to cancel the waiting.

How do I code this?  I probably need some sleep() stuff between each
InTransAction check, but I would appreciate some snippets with elegant

Thanks in advance




Re:InTransaction dialog

What database are you using? InTransaction will only be True if you have an
active transaction. It will not tell you if other users have active
transactions. One of the purposes of transactions is to allow multiple users
to update a database concurrently and safely. It sounds like what you want
is some kind of semephore to force single user access. If so, add a table
with one record to your database. Start a transaction, change the value of a
field in the record and post the change. If the post is successful you now
have that record locked, which means that no other user has it locked. When
your transaction commits or rolls back the lock will be released so another
user will be able to acquire the lock.

Bill Todd (TeamB)
(Questions received via email cannot be answered.)

Other Threads