J
John Lee
Hi,
If I develop a component A and create a method DoSomething(string
connectionString) and I have another component B with a method
DoOtherThing(string connectionString)
and from inside DoSomething() the B.DoOtherThing() will be called like
public class A
{
public void DoSomething(string connectionString)
{
using (new TransactionScope())
{
using (SqlConnection cn = new SqlConnection(connectionString))
{
//do some db change here
}
//call B
B o = new B();
o.DoOtherThing(connectionString);
}
}
If there is an exception in B.DoOtherThing, the change in A will not be
saved, right? according to the document, this should work, my question is in
COM+ world, I will have to make component A "transaction.required" and make
component B "transaction.supported" so the transaction context will actually
span two component - but in .NET 2.0, the component B totally unaware of the
context except being called inside the TransactionScope - how does this work
and how could I specifically to abort the transaction in certain condition?
Do I have to pass some transaction object to B?
Thanks very much!
John
If I develop a component A and create a method DoSomething(string
connectionString) and I have another component B with a method
DoOtherThing(string connectionString)
and from inside DoSomething() the B.DoOtherThing() will be called like
public class A
{
public void DoSomething(string connectionString)
{
using (new TransactionScope())
{
using (SqlConnection cn = new SqlConnection(connectionString))
{
//do some db change here
}
//call B
B o = new B();
o.DoOtherThing(connectionString);
}
}
If there is an exception in B.DoOtherThing, the change in A will not be
saved, right? according to the document, this should work, my question is in
COM+ world, I will have to make component A "transaction.required" and make
component B "transaction.supported" so the transaction context will actually
span two component - but in .NET 2.0, the component B totally unaware of the
context except being called inside the TransactionScope - how does this work
and how could I specifically to abort the transaction in certain condition?
Do I have to pass some transaction object to B?
Thanks very much!
John