Re: Number of open transactions in DAO

Tech-Archive recommends: Fix windows errors by optimizing your registry



You're utilizing the concept of Transactions in a manner that they were never intended for. The idea behind transactions is to ensure that all updates (or deleted) across multiple tables in a database can succeed prior to committing them.

Which leads me to the next question, what information is in the listbox and why do you *NEED* to control its content?

Dirk wrote:
Since I am controlling my listbox's content by controlling it's recordset I want to do non comitting updates on it's recordset. Therefore I call Workspace.BeginTrans in my form's OnOpen event. I commit when the user presses the save button (which will also add more info to the records in the recordset) and rollback on the form's OnClose event. Errors will perform a rollback too.
My form class has some properties that are initialised in the OnOpen event, like:


wrkSpace = DBEngine.Workspaces(0)
dbConn = Workspaces.OpenDatabase(...)
rsRules = dbConn.OpenRecordset(sql)

Keeping track of the number of transactions works fine. However my msaccess.exe now reproducably crashes everytime I call Workspace.Rollback, especially if I have first made changes in a recordset. Have reproduced this behavior on two different Compaq nc6120 laptops. Though I guess I should report this to Microsoft support, right?

"David C. Holley" wrote:


How are you structuring your code? In all of the examples that I've seen .BeginTrans, .CommitTrans and .RollBack have always been used in blocks (a la IF...END IF statements) of code and not orphaned across multiple SUBS?

Dirk wrote:

Hi,

How do I check wether a transaction is open in a DAO workspace before calling .Rollback on it? I need this for cleaning up but calling .Rollback or .CommitTrans when there is no transaction causes a runtime error.

.


Quantcast