473,387 Members | 3,801 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Scope of transaction processing wrapper

I have some unbound forms that I want to use transaction wrappers on when
updating the table. My question is on the scope of what transaction
processing will do. I'm going to keep it simple with the following code:
Code:
------------------------------------------------------------------------------
--

ws.BeginTrans
bInTrans = True

'Delete record from TableA
rs.Delete

'Now update TableB
Call WriteMasterTableRecord(RecordtoDelete, ValueA, ValueB)

'Now update some information in TableC
Call StatusAsMaster(MasterID, ValueD)

ws.CommitTrans
bInTrans = False
------------------------------------------------------------------------------
--
Again, the code has been simplified.

What I want to know is if the transaction wrapper for TableA also covers
TableB and TableC which are updated in other procedures. In my exit handler
there is the following:

If bInTrans = True Then
ws.Rollback
End If

So, if an error occurs, the Error_Handler is invoked and then the exit
handler. Will the Rollback statement roll back the changes to all three
tables (A, B and C) or will it only roll back Table A??

--
Message posted via http://www.accessmonster.com
Mar 13 '06 #1
3 2693
The answer to your question depends on how you write the changes to the
other tables.

If you write the changes with something like:
db.Execute ...
where db is the database in the ws workspace, then they will rollback.

But they will not roll back if you make the changes with (say) RunSQL, or
through another Workspace variable, since these are outside of the scope of
your transaction.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"rdemyan via AccessMonster.com" <u6836@uwe> wrote in message
news:5d2e8b9dbc994@uwe...
I have some unbound forms that I want to use transaction wrappers on when
updating the table. My question is on the scope of what transaction
processing will do. I'm going to keep it simple with the following code:
Code:
------------------------------------------------------------------------------
--

ws.BeginTrans
bInTrans = True

'Delete record from TableA
rs.Delete

'Now update TableB
Call WriteMasterTableRecord(RecordtoDelete, ValueA, ValueB)

'Now update some information in TableC
Call StatusAsMaster(MasterID, ValueD)

ws.CommitTrans
bInTrans = False
------------------------------------------------------------------------------
--
Again, the code has been simplified.

What I want to know is if the transaction wrapper for TableA also covers
TableB and TableC which are updated in other procedures. In my exit
handler
there is the following:

If bInTrans = True Then
ws.Rollback
End If

So, if an error occurs, the Error_Handler is invoked and then the exit
handler. Will the Rollback statement roll back the changes to all three
tables (A, B and C) or will it only roll back Table A??

Mar 13 '06 #2
Allen:

Thank you for the response. I'm using different DAO workspace, database and
recordset variables in the procedures that update Tables B and C. I'm not
using db.Execute type statements, but instead rsXXX.AddNew or rsXXX.Edit and
rsXXX.Update.

Does this mean that I should pass the DAO variables that update TableA into
the procedures that update TablesB and C. Do I just pass in the ws and db
variables and then create a new recordset based on the SQL statement that is
appropriate for each procedure to accomplish that procedure's job?

If so, I assume that these DAO variables should still be closed in the
original module that created them (i.e. where TableA is updated).

Thanks.

Allen Browne wrote:
The answer to your question depends on how you write the changes to the
other tables.

If you write the changes with something like:
db.Execute ...
where db is the database in the ws workspace, then they will rollback.

But they will not roll back if you make the changes with (say) RunSQL, or
through another Workspace variable, since these are outside of the scope of
your transaction.
I have some unbound forms that I want to use transaction wrappers on when
updating the table. My question is on the scope of what transaction

[quoted text clipped - 35 lines]
handler. Will the Rollback statement roll back the changes to all three
tables (A, B and C) or will it only roll back Table A??


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200603/1
Mar 13 '06 #3
Yes, that all sounds right.

Just pass the Database variable, and it will all rollback.

This article illustrates transactions:
http://allenbrowne.com/ser-37.html
It all happens in one procedure, so it does not illustrate passing the db,
but the technique is identical, and it does explain a couple of traps.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"rdemyan via AccessMonster.com" <u6836@uwe> wrote in message
news:5d32b3ce99067@uwe...
Allen:

Thank you for the response. I'm using different DAO workspace, database
and
recordset variables in the procedures that update Tables B and C. I'm not
using db.Execute type statements, but instead rsXXX.AddNew or rsXXX.Edit
and
rsXXX.Update.

Does this mean that I should pass the DAO variables that update TableA
into
the procedures that update TablesB and C. Do I just pass in the ws and db
variables and then create a new recordset based on the SQL statement that
is
appropriate for each procedure to accomplish that procedure's job?

If so, I assume that these DAO variables should still be closed in the
original module that created them (i.e. where TableA is updated).

Thanks.

Allen Browne wrote:
The answer to your question depends on how you write the changes to the
other tables.

If you write the changes with something like:
db.Execute ...
where db is the database in the ws workspace, then they will rollback.

But they will not roll back if you make the changes with (say) RunSQL, or
through another Workspace variable, since these are outside of the scope
of
your transaction.
I have some unbound forms that I want to use transaction wrappers on when
updating the table. My question is on the scope of what transaction

[quoted text clipped - 35 lines]
handler. Will the Rollback statement roll back the changes to all three
tables (A, B and C) or will it only roll back Table A??


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200603/1

Mar 13 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Tim Callaghan | last post by:
We have an inhouse replication process which is causing us headaches when we try to run more than one copy of it against the same target database (we support unlimited remote databases so we may...
0
by: Manoj Sharma | last post by:
I am performance testing some batch processing engines. These are written in ..NET and SQL Server and are typically concerned with generating XML files out of data retrieved from the database. I...
15
by: Zeng | last post by:
Hi, The bigger my C# web-application gets, the more places I need to put in the tedious retrying block of code to make sure operations that can run into database deadlocks are re-run (retried)...
0
by: LBS | last post by:
Hello guys I'm trying to implement a wrapper class, and I'm havinf difficulty implementing the transaction. I have several classes. The wrapper WrapDbCommand, WrapConnection..etc, and the...
5
by: Allan Ebdrup | last post by:
I'm using dotNet 2.0 and System.Transactions to run transactions that span multiple database queries, Now I would like to log any Sql errors that occur in the transaction, but when I insert the...
3
by: GaryDean | last post by:
I'm using TransactionScope as follows... using TransactionScope myScope = new TransactionScope()) { using (SqlConnection conn = new SqlConnection()) { conn.ConnectionString =...
1
ADezii
by: ADezii | last post by:
Transaction Processing is a Database term that refers to the process of grouping changes to your data into a batch that is treated as a single, atomic unit. Either the entire batch of transactions...
0
ADezii
by: ADezii | last post by:
In the Tip of the Week #19, we demonstrated Transaction Processing, specifically as it applies to DAO (Data Access Objects). In this week's Tip, we'll illustrate how Transaction Processing can be...
0
by: =?Utf-8?B?Sm9l?= | last post by:
Very weird; I lost a day worth of work because of this problem. I have an ASP.NET application written in VB that is using MySQL database. Shortly, a page creates a Customer record in the database...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.