473,396 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

try block processing path

In the following try catch block can I guarantee that part b will not execute
if part a throws exception

try {
part a
part b
}
catch (Exception ex) {
do something
}
finally {
dispose of any thing needed
}

I am doing a DB update in part a and an insert in part b based on part a
data. I need to make sure that part a is successful before doing part b.

Part b could be multiple items from a listbox that may or may not be
different then what's already in the table. I could delete all and then
insert these but I have to make sure that part a completed successfully. Then
if part b fails I need to rollback any of the changes.

Thanks
Nov 18 '05 #1
2 806
The answer to your question is yes, it is guaranteed.

May be you should consider using database transactions to ensure data
integrity.

Eliyahu

"Marty U." <Ma****@discussions.microsoft.com> wrote in message
news:EB**********************************@microsof t.com...
In the following try catch block can I guarantee that part b will not execute if part a throws exception

try {
part a
part b
}
catch (Exception ex) {
do something
}
finally {
dispose of any thing needed
}

I am doing a DB update in part a and an insert in part b based on part a
data. I need to make sure that part a is successful before doing part b.

Part b could be multiple items from a listbox that may or may not be
different then what's already in the table. I could delete all and then
insert these but I have to make sure that part a completed successfully. Then if part b fails I need to rollback any of the changes.

Thanks

Nov 18 '05 #2
I would love to use DB transactions however the situation I am in is not
feasible necessarily.

I am updating one record in one table and then I have to do a loop through
an arraylist and perform an insert into another table. I have decided it will
be best to do a delete then insert instead of doing an update or add routine.
My problem is I don't want one change taking place if the other fails.

So basically I would like to execute many SQLCommands under one transaction
object. I believe I can do this with ADO.Net transactions on the page. I
normally use all stored procedures and perform my transactions from there but
now I needed to execute all the sp commands under a single transaction object.

Marty

"Eliyahu Goldin" wrote:
The answer to your question is yes, it is guaranteed.

May be you should consider using database transactions to ensure data
integrity.

Eliyahu

"Marty U." <Ma****@discussions.microsoft.com> wrote in message
news:EB**********************************@microsof t.com...
In the following try catch block can I guarantee that part b will not

execute
if part a throws exception

try {
part a
part b
}
catch (Exception ex) {
do something
}
finally {
dispose of any thing needed
}

I am doing a DB update in part a and an insert in part b based on part a
data. I need to make sure that part a is successful before doing part b.

Part b could be multiple items from a listbox that may or may not be
different then what's already in the table. I could delete all and then
insert these but I have to make sure that part a completed successfully.

Then
if part b fails I need to rollback any of the changes.

Thanks


Nov 18 '05 #3

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

Similar topics

6
by: Ramon M. Felciano | last post by:
Helo all -- I'm trying to gain a deeper understand for what type of semi-declarative programming can be done through XML and XPath/XSLT. I'm looking at graph processing problems as a testbed for...
3
by: Travis | last post by:
I am trying to prevent an exception from bubbling up from one nested Try/Catch Block to its "Parent" Try/Catch Block. Here is some example code: try{ try{ //Non-application killing code that...
6
by: James Radke | last post by:
Hello, I have a multithreaded windows NT service application (vb.net 2003) that I am working on (my first one), which reads a message queue and creates multiple threads to perform the processing...
11
by: | last post by:
Is it possible to define a variable in a block in order to make it invisible outside that block? For example, in C I can write { int a .... } then a will only be available inside the curley...
4
by: hzgt9b | last post by:
Using VB .NET 2003, I have a windows application that performs a series of file actions (copy, move, delete) but the actions are completing before the window is painted on the screen... how can I...
0
by: Robert | last post by:
After failing on a yield/iterator-continuation problem in Python (see below) I tried the Ruby (1.8.2) language first time on that construct: The example tries to convert a block callback interface...
2
by: vectorizor | last post by:
Hi all, I am writing an image processing algorithm that goes across an image first row-wise and then column-wise. For illustration purposes, imagine that for every pixels, the output is computed...
4
by: tech | last post by:
Hi, I need to pass a block of say 320 bytes memory between some classes which do various processing on it. The app needs to be quick so i can't keep copying. The simplest way is via pointer...
3
by: Richard | last post by:
Again, new to DB2. Trying to do something I can do in Sybase ASE. In any Sybase SQL script I can use /* */ to comment out a block of code. In the DB2 9.0 SQL Reference Manual V1 it says: ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.