472,325 Members | 1,500 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,325 software developers and data experts.

How to raise an event when a transaction is rollbacked

Hello,

I've got a few stored procedure called made within one sqlTransaction
object.

If the .Rollback() method of the transaction is called, then I would
like some extra code to be executed. The issue is that the .Rollback()
method can be called from many different places so I don't want to
write this code in all those places. Therefore how can I add an event
handler to this method, so that each time it is called, an event is
raised, which will then execute my code ?

Thank you

Aug 8 '06 #1
4 1206
Graphix,

Why not just make a module or a shared class from which you can call the
method?

Cor

"graphicsxp" <sa*************@googlemail.comschreef in bericht
news:11**********************@h48g2000cwc.googlegr oups.com...
Hello,

I've got a few stored procedure called made within one sqlTransaction
object.

If the .Rollback() method of the transaction is called, then I would
like some extra code to be executed. The issue is that the .Rollback()
method can be called from many different places so I don't want to
write this code in all those places. Therefore how can I add an event
handler to this method, so that each time it is called, an event is
raised, which will then execute my code ?

Thank you

Aug 8 '06 #2
I suppose I could do that... but I thought raising an event sounds
better, i don't have to share anything then.
Cor Ligthert [MVP] wrote:
Graphix,

Why not just make a module or a shared class from which you can call the
method?

Cor

"graphicsxp" <sa*************@googlemail.comschreef in bericht
news:11**********************@h48g2000cwc.googlegr oups.com...
Hello,

I've got a few stored procedure called made within one sqlTransaction
object.

If the .Rollback() method of the transaction is called, then I would
like some extra code to be executed. The issue is that the .Rollback()
method can be called from many different places so I don't want to
write this code in all those places. Therefore how can I add an event
handler to this method, so that each time it is called, an event is
raised, which will then execute my code ?

Thank you
Aug 8 '06 #3

How about ... extending the sqlTransaction object and create you own ...

- inherit from the sqlTransaction object...
- mySqlTransaction Object ...
- add you event there ... myRollBackExtended ...
- If you can, Override the .Rollback and include your raiseent here ...
- If you can not override the .Rollback, create you own .MyRollBack and us
it (this would required you to replace the .Rollback call with myRollback
call ... global / find and replace) ...

Now, in your program, instead of using the sqlTransaction object, use your
MySqltransaction object ... and you will have you custom events ...

to change you code ... use the global / find and replace ...

Find ...

System.Data.SqlClient.SQLTransaction or Data.SqlClient.SQLTransaction or ...
how ever declare it...

Replace

<myproject>.<mynamespace>.mySqltransaction

Sorry this does not work ... sqlTransaction is non-inheritable (do not know
why) ... should have checked before I wrote a response ... too bad ...

However, all is not lost, you could wrap the sqlTransaction in your own
object ... with sqlTransaction as a property / member ... and use your
custom object to extend the rollback functionality... basically, this wold
be a little 'overhead' up front (programming), but it will allow you to
'customize' or 'extend' the functionality of the sqlTransaction object ...
and will put all your code in one place ... and not spreadout over a few
modules or shared classes ... This design allow you to 'reliably' capture
those instances when you need to 'extend' the rollback, without having to
remember to 'include a call another shared class event'...

Jeff.

"graphicsxp" <sa*************@googlemail.comwrote in message
news:11**********************@i42g2000cwa.googlegr oups.com...
>I suppose I could do that... but I thought raising an event sounds
better, i don't have to share anything then.
Cor Ligthert [MVP] wrote:
>Graphix,

Why not just make a module or a shared class from which you can call the
method?

Cor

"graphicsxp" <sa*************@googlemail.comschreef in bericht
news:11**********************@h48g2000cwc.googleg roups.com...
Hello,

I've got a few stored procedure called made within one sqlTransaction
object.

If the .Rollback() method of the transaction is called, then I would
like some extra code to be executed. The issue is that the .Rollback()
method can be called from many different places so I don't want to
write this code in all those places. Therefore how can I add an event
handler to this method, so that each time it is called, an event is
raised, which will then execute my code ?

Thank you

Aug 8 '06 #4
Hi Jeff,
thanks for the long reply. Actually I've opted for the second solution
you offered (to wrap the SQLTransac object) and that works fine.
thanks again,

Aug 9 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Dan Cimpoiesu | last post by:
I have a remoting object, derived from MarshalByRefComponent, that I instantiate on the client side, with Activator.GetObject. Can I receive events...
1
by: BC | last post by:
Hi all, I have two classes: TransactionCollection and Transaction, where TransactionCollection is used to store Transaction objects. public...
4
by: Charles Law | last post by:
Suppose a worker thread needs to signal to the main thread that an event has occurred. Ordinarily, any event raised by the worker thread will be on...
3
by: moondaddy | last post by:
I wrote my own List class which I use to bind to list controls. this class inherits CollectionBase and implements IBindingList. This class...
1
by: Anonieko | last post by:
I know Visual Studio lacked support on easily writing code to raise events from a ascx user control ( because you have to hand write them)....
1
by: Manu Singhal | last post by:
Hi I want to know how can one use TransactionScope with the CreateUserWizard Contrrol I have to update a Table in my database if the user is...
3
by: =?Utf-8?B?Ulc=?= | last post by:
I constructed a new Class with some private members. I would like an event to be raised on the moment the value of one of those private members is...
5
by: Mike | last post by:
Hi group; Let say I have an object called Account, that raises an event called AccountLow with its owns EventArgs, and when this event...
3
by: Rahul Babbar | last post by:
Hi All, When could be the possible reasons that could make a database inconsistent? I was told by somebody that it could become inconsistent...
0
by: tammygombez | last post by:
Hey fellow JavaFX developers, I'm currently working on a project that involves using a ComboBox in JavaFX, and I've run into a bit of an issue....
0
by: tammygombez | last post by:
Hey everyone! I've been researching gaming laptops lately, and I must say, they can get pretty expensive. However, I've come across some great...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.