?
Solved

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

Posted on 2007-11-15
3
Medium Priority
?
691 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
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…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

718 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