Transaction between classes

  • Thread starter Thread starter Kris Muylaert
  • Start date Start date
K

Kris Muylaert

Hi,

I have different classes that are performing database operations. Sometimes
1 fuction in a class, calls another function in another class (maybe in a
different assembly), but both need to be enlisted in the same transaction.

What do I have to do? Pass the connection object as a parameter in the
function, or pass the transaction object as parameter? Byval or Byref?

Remark: I can't use Com+ or MSMQ since all assemblies are running on a
client machine

Thanks,
Kris
 
Kris Muylaert said:
Hi,

I have different classes that are performing database operations. Sometimes
1 fuction in a class, calls another function in another class (maybe in a
different assembly), but both need to be enlisted in the same transaction.

What do I have to do? Pass the connection object as a parameter in the
function, or pass the transaction object as parameter? Byval or Byref?

Remark: I can't use Com+ or MSMQ since all assemblies are running on a
client machine


You need to share both the connection and the transaction. So you must pass
both, or use a global connection and transaction. In a winforms application
the easiest thing to to is to just open one connection and share it among
all your types using a global or static variables.


David
 
Kris,

Pass the transaction rather than the connection. You can get the connection
from the transaction object via its Connection property. There's no need to
pass the transaction byref since a byval pass will pass a reference to the
object anyway (i.e.: calls to methods of the object will operate on the same
copy of the object, just from a separate reference).

HTH,
Nicole
 
Thanks for the answer.
-----Original Message-----
Kris,

Pass the transaction rather than the connection. You can get the connection
from the transaction object via its Connection property. There's no need to
pass the transaction byref since a byval pass will pass a reference to the
object anyway (i.e.: calls to methods of the object will operate on the same
copy of the object, just from a separate reference).

HTH,
Nicole


operations.


.
 
Back
Top