-----------------------------------------------------------

New Message on BDOTNET

-----------------------------------------------------------
From: Neeraj_Bangalore
Message 5 in Discussion

 Hi Dinesh,     In my opinion, the data once commited cannot be rollback. So, if your 
code of class1 looks something like this :    BeginTransaction.     Code for 
Insert/Update/Delete     x = SomeReturnedValue CommitTransaction   following which 
some method of Class2 executes where the code is something like this    
BeginTransaction Try      Use x     Code for Insert/Update/Delete     commit catch     
 rollback end try    See, here the transaction of class one is already over, so any 
code ( including RollBack of any other transaction ) after that will not affect the 
database.    But If you want that On failure of insert statement of Class2, the 
transaction of class1 also should be rollback, then you will have to write code 
someting like this    In Class1   BeginTransaction  Try      Insert Statement for 
first part ( Class1 Part )      x = SomeReturnValue      ------- Instantiate Class2, 
Like say, Dim objClass2 as Class2()          objClass2.InsertData(x)     
CommitTransaction Catch     RollBack End Try   And in the InsertData method of Class2, 
don't use the begin transaction and commit/Rollback          Sub InsertData(ByVal x As 
.. ...)         code for using x and inserting the data     end sub    And if, you 
really want to use the transaction in the class2 and also wants that the failure of 
this should also rollback the first transaction, then do it this way   Sub 
InsertData(ByVal x As ........)     Begin Transacation2      Try              code for 
using x and inserting the data             CommitTransaction2     Catch              
RollBack Transcation2             Throw Exception from here, which will be caught by 
Try of Class1     End Try    And if the things are getting complex then better use 
Stored Procedure, where you write all the logic that you are writing in both the 
class1 and class2.    In case of any issues, please do revert back.... 
Regards,
Neeraj Saluja
SCT Software Solutions, Bangalore

-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/bdotnet/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you received 
this message by mistake, please click the "Remove" link below. On the pre-addressed 
e-mail message that opens, simply click "Send". Your e-mail address will be deleted 
from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to