M
Mukesh
Hi,
I am new to 2.0 framework. I am trying to use TransactionScope in the
following code. I took four lables. Started TransactionScope scope.
After setting values to three labels I throw an exception. I expexted
all label value would remain as method Complete() of TransactionScope
scope was not complete. But actually three labels are showing new
values.
label1.Text="1";
label2.Text="1";
label3.Text="1";
label4.Text="1";
private void Change_Label()
{
using (TransactionScope scope = new TransactionScope())
{
Exception ee = new Exception("My Exception");
try
{
label1.Text = "0";
label2.Text = "0";
label3.Text = "0";
throw ee;
label4.Text = "0";
scope.Complete();
}
catch (Exception ex)
{
MessageBox.Show("Transaction not completed");
}
}
}
Can't we use TransactionScope in these situations? Is there alternate
solution? What if instead of statements, few methods were called each
operationg on different rows. Suppose I have three different method
m1(); m2(); m3() and insert one row each in table t1,t2 and t3
respectively. In a sample run after execution of m1() and m2() an
Exception occured. Would it mean no new row in t3 as well as t1 and
t2.
Thanks
Mukesh
I am new to 2.0 framework. I am trying to use TransactionScope in the
following code. I took four lables. Started TransactionScope scope.
After setting values to three labels I throw an exception. I expexted
all label value would remain as method Complete() of TransactionScope
scope was not complete. But actually three labels are showing new
values.
label1.Text="1";
label2.Text="1";
label3.Text="1";
label4.Text="1";
private void Change_Label()
{
using (TransactionScope scope = new TransactionScope())
{
Exception ee = new Exception("My Exception");
try
{
label1.Text = "0";
label2.Text = "0";
label3.Text = "0";
throw ee;
label4.Text = "0";
scope.Complete();
}
catch (Exception ex)
{
MessageBox.Show("Transaction not completed");
}
}
}
Can't we use TransactionScope in these situations? Is there alternate
solution? What if instead of statements, few methods were called each
operationg on different rows. Suppose I have three different method
m1(); m2(); m3() and insert one row each in table t1,t2 and t3
respectively. In a sample run after execution of m1() and m2() an
Exception occured. Would it mean no new row in t3 as well as t1 and
t2.
Thanks
Mukesh