473,564 Members | 2,798 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 4714
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******** ******@TK2MSFTN GP09.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(SqlTran saction tran)
{
if (tran == null)
// create new connection
else
// use existing conn (tran.Connectio n)
}

--
Dave Sexton
dave@www..jwaon line..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******** ******@TK2MSFTN GP09.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
11587
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 be updated when a group of items is copied. I can successfully do this with cursors, but am experimenting with a way to do it with a single update...
4
1498
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... <code> class User: def View(self):
1
1860
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 commands to execute all thiis sentene from VB.
1
2924
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 work (error that there is an extra parenthise (sp?) ) and B: Will only let in two names for each record. If there are three, the middle on is...
2
1769
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 multiple times. The easiest way to describe the problem is to just show you. In my Page_Load() I have this code:
12
2194
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 one: Private Sub SunMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SunMenuItem.Click If SunMenuItem.Checked...
2
1115
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 function: __main__.Watcher.processUpdate % 12:45:24.95 tag function: __main__.Watcher.processUpdate % 12:45:55.12 tag function:...
3
7973
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) values (1,2) go 1000
2
1741
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 menus, but didn't have too much luck. Suggestions?
0
7665
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7583
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8106
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6255
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2082
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1200
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
924
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.