Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2007-11-15
3
Medium Priority
?
694 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 46

Accepted Solution

by:
Kent Olsen earned 600 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 600 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 300 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

824 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