Solved

How to work with client side transactions in VB.net for DB2 DSN

Posted on 2007-11-15
3
667 Views
Last Modified: 2008-02-07
I have an application in VB.net that does inserts into three different tables. Insert into table 1 is done by DB2 stored procedure1. Insert into table 2 DEPENDS on the success of the insert into table 1 and is achieved by a DB stored procedure 2. Insert into table 3 depends on success of inserts into table2 [hence success of insert into table1] and is done with a DB2 stored procedure 3.

Now, when i am at the insert into table3 [assuming that inserts 1 and 2 have completed successfully] and the insert FAILS, I want to ROLLBACK the inserts into table 2 and inserts into table 1. Now, I cannot change the stored procedure because this is a 3 tier development architecture where the database objects are shielded from the "view" layer [this is not a WEB APP]. I have three methods that do these inserts.

I have heard of this "transaction scope" object in .net but I do not see a "rollback" option in there. So, my question is how would I go about coding the "rollback" transaction option to this scenario? More than the commit, I need the rollback.

App: Vb.net, database:DB2 on Z/os[mainframe]
0
Comment
Question by:VBSolutionSeeker
3 Comments
 
LVL 45

Accepted Solution

by:
Kdo earned 200 total points
ID: 20289866
Hi VBSolutionSeeker,

A transaction is a logical unit of work.  (Silly words right out of the 'manual'.)  Support for running in a transaction environment varies with the different clients and applications.

But I know of no way to maintain a transaction across multiple connections.  If your application connects, runs procedure1 and disconnects, then reconnects to run procedure2, the updates performed by procedure1 are already committed.  You can not roll them back.

Also, if the procedure does an explicit commit, you're in the same situation.  DB2 doesn't care where the commit is initiated.  A commit is a commit.

All that said, what you probably want is middleware that will maintain a connection to DB2 and allow your VB code to interact with it.  It's not necessarily cheap, and it will require a significant amount of recoding on your end.


Good Luck,
Kent
0
 
LVL 5

Assisted Solution

by:ocgstyles
ocgstyles earned 200 total points
ID: 20292259
Hi VBSolutionSeeker,

I agree with Kdo.

But if there's the slight chance you can combine the 3 stored procedures into 1, then you could just make it an atomic transaction.  When atomic, its all or none.  If SP2 failed, so does 1, if SP3 fails, so does 1 and 2.

But like you said, that's not an option...

Keith
0
 
LVL 27

Assisted Solution

by:tliotta
tliotta earned 100 total points
ID: 20295605
Minor question... does "cannot change the stored procedure" also mean that a new stored proc _cannot_ be created?

Tom
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now