transaction span methods/objects

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi there,

In my app, all queries from different methods/objects have to be in one
transaction (to a single DB). I think that there is a basic way to so that is
pass the same connection and transaction from the beginning of process all
the way down to the end and commit there. Since they are talking to a single
DB, Automatic (COM+) transactions may not be needed.

Any one has better ways? Thanks for your help.
 
If you don't want to use COM+, the better way is to pass
command (init its transcation from the beginning) by
reference thru all processes.

Elton Wang
(e-mail address removed)
 
Thanks.

I guest I have to pass both so that I can let some queries be out of the
transaction.
 
DHuang said:
Thanks.

I guest I have to pass both so that I can let some queries be out of the
transaction.
In most database systems enlisting commands in the current transaction is
not optional. For SQL Server manual enlisting is required, and for Oracle
it happens automatically.

An alternative to passing the connection and transaction as input parameters
is to put them in thread-local storage using a [ThreadStatic()] static
variable. Then every method can share the same open connection and
transaction without having to pass them around as input parameters.

David
 
Cannot do that in this way. Once a transaction is started, all commands with
the connection have to be with the transaction. Otherwise, an exception is
thrown.
 
Back
Top