473,499 Members | 1,609 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Same Transaction, multiple methods. How to do it?

In a C# Windows Forms application, using the SqlClient data provider...

I have methodA() and methodB().

methodA starts a transaction on its own command and conection objects, does
bunch of stuff, then either commits or rollsback the transaction.

methodA calls methodB many times.

methodB creates its own connection and command objects and does a bunch of
other stuff.

How can I get the command and connection objects of methodB to participate
in the transaction in methodA?

Thanks!
Nov 17 '05 #1
2 4706
I've not tried this, but maybe you'll have to pass your transaction object
to Method B as a parameter, and enlist method B's stuff in the transaction.
You'll have to use the same connection being used in Method A as well, I'd
think.

Hope this helps,

Anne
"Frankie" <A@B.COM> wrote in message
news:OU**************@TK2MSFTNGP09.phx.gbl...
In a C# Windows Forms application, using the SqlClient data provider...

I have methodA() and methodB().

methodA starts a transaction on its own command and conection objects,
does bunch of stuff, then either commits or rollsback the transaction.

methodA calls methodB many times.

methodB creates its own connection and command objects and does a bunch of
other stuff.

How can I get the command and connection objects of methodB to participate
in the transaction in methodA?

Thanks!

Nov 17 '05 #2
You can just pass the transaction class which provides a reference to the connection.

public void MethodB(SqlTransaction tran)
{
if (tran == null)
// create new connection
else
// use existing conn (tran.Connection)
}

--
Dave Sexton
dave@www..jwaonline..com
-----------------------------------------------------------------------
"Anne Nolan" <an***************@AOL.COM> wrote in message news:3j************@individual.net...
I've not tried this, but maybe you'll have to pass your transaction object to Method B as a parameter, and enlist method B's stuff
in the transaction. You'll have to use the same connection being used in Method A as well, I'd think.

Hope this helps,

Anne
"Frankie" <A@B.COM> wrote in message news:OU**************@TK2MSFTNGP09.phx.gbl...
In a C# Windows Forms application, using the SqlClient data provider...

I have methodA() and methodB().

methodA starts a transaction on its own command and conection objects, does bunch of stuff, then either commits or rollsback the
transaction.

methodA calls methodB many times.

methodB creates its own connection and command objects and does a bunch of other stuff.

How can I get the command and connection objects of methodB to participate in the transaction in methodA?

Thanks!


Nov 17 '05 #3

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

Similar topics

8
11576
by: pb648174 | last post by:
I have a single update statement that updates the same column multiple times in the same update statement. Basically i have a column that looks like .1.2.3.4. which are id references that need to...
4
1488
by: Rob Conner | last post by:
No you don't need to know Zope to help me. The whole reason I'd even want to do this is because of Zope though. I made a Zope product, and now want to perfect it. some simple example code... ...
1
1856
by: NKN | last post by:
Hi all, Does anybody know how could I manage to do a sentence like this... ALTER TABLE Table1 DROP COLUMN Col1 after doing a DML sentence like and UPDATE, INSERT or DELETE. I'm using ADO...
1
2919
by: Phoenix_ver10 | last post by:
I have a mailing list with multiple names going to the same addresses. I need one address with all the names for that address on it. I checked out the example on microsoft's site, but A: It doesn't...
2
1762
by: Alan Foxmore | last post by:
Hi Everyone, I'm new to ASP.NET so maybe this is easy. I'm using ASP.NET 2.0. I'm finding that the Application object (the HttpApplicationState object) is allowing me to add the same key...
12
2184
by: cj | last post by:
I would like to have menu items a main menu bar that represent the days of the week. When you click on them they alternate from checked to unchecked. Right now I have 7 subs that look like this...
2
1112
by: skip | last post by:
I'm trying some stuff with Psyco and am confused about its apparent desire to compile the same function (or method) multiple times). Here's an abstract from a recent run: 12:45:15.99 tag...
3
7959
by: Ultrak The DBA | last post by:
As a converted sybase dba, I have a question. In sybase a command can be executed multiple times by placing a go 1000 at the end of the statement. Such as: insert into a (col1, col2)...
2
1732
by: FaurKris | last post by:
I need to report the day, time, supplier, etc. for multiple selected suppliers from the same form. How can I use the same items from the field list on the same form? I tried the drop down...
0
7134
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
7014
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
7180
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
7229
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...
1
6905
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
7395
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5485
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,...
1
667
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
311
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.