Get transaction object from a connection

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

Guest

After I begin a transaction: e.g: IDbTransaction aTran =
aConn.BeginTransction();

I see in the debug window a lot of member of the connection such as:
_transaction, HasTransaction, Transaction,..

But I can not get the values of them in my code, I guess they are private
members.

Is there the way to get the active transaction object from aConn object
(suppose I miss aTran object).
 
It's not on the DbConnection, so no, you cannot get it from there.

If you are using a DTC transaction (which is signifcantly slower than a
regular client-side DbTransaction), its 'globally' available to all commands
on the original connection.

HTH,

Howard Hoffman
 
If you are using a DTC transaction (which is signifcantly slower than a
regular client-side DbTransaction), its 'globally' available to all
commands on the original connection.

Hmmmmmm .... mayyybee. ;-). You could have code blocks that choose not to
enlist within a DTC transaction. And DTC transaction has nothing to do with
Connection.BeginTransaction - so this won't lead u that way. Though there is
a way to get to the SqlTransaction through
System.Transactions.Transaction.Current if you are still with LTM (i.e. not
promoted to MSDTC).

- Sahil Malik [MVP]
ADO.NET 2.0 book -
http://codebetter.com/blogs/sahil.malik/archive/2005/05/13/63199.aspx
__________________________________________________________
 
Back
Top