473,813 Members | 3,898 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Passing DBTransaction between functions in Bus Layer

Hi all

I have a function setup in my Bus Logic Layer similar to the following
function ProcessOrders
function InsertOrder
function InsertOrderItem s

I need to be make sure all functions use the same Transaction (Enterprise
Lib DbTransaction object) between method calls.

How shoudl I lat this out?

Cheers

S

Jun 27 '08 #1
3 3512
The most practial solution would be TransactionScop e; apart from not
requiring any work, any other code that uses suitable connections can
also enlist, it supports distributed transactions, and nesting is
supported (as are isolation levels, non-transactional blocks, etc).

Example: add a reference to System.Transact ions, then

// cheesy example ;-p
static void Transfer(int fromAccount, int toAccount, int amount)
{
using (TransactionSco pe tran = new TransactionScop e())
{
Debit(fromAccou nt, amount);
Credit(toAccoun t, amount);
tran.Complete() ;
}
}

On SQL2000, it uses DTC from the outset (since SQL2000 transactions
aren't promoteable) - but on SQL2005 it uses the "LTM" (lightweight
transaction manager) to start with a SQL transaction, and promote that
to a DTC transaction if necessary (for instance you start talking to a
second server...).

Marc
Jun 27 '08 #2
thanks marc!

"Marc Gravell" <ma**********@g mail.comwrote in message
news:5a******** *************** ***********@a23 g2000hsc.google groups.com...
The most practial solution would be TransactionScop e; apart from not
requiring any work, any other code that uses suitable connections can
also enlist, it supports distributed transactions, and nesting is
supported (as are isolation levels, non-transactional blocks, etc).

Example: add a reference to System.Transact ions, then

// cheesy example ;-p
static void Transfer(int fromAccount, int toAccount, int amount)
{
using (TransactionSco pe tran = new TransactionScop e())
{
Debit(fromAccou nt, amount);
Credit(toAccoun t, amount);
tran.Complete() ;
}
}

On SQL2000, it uses DTC from the outset (since SQL2000 transactions
aren't promoteable) - but on SQL2005 it uses the "LTM" (lightweight
transaction manager) to start with a SQL transaction, and promote that
to a DTC transaction if necessary (for instance you start talking to a
second server...).

Marc
Jun 27 '08 #3
No problem; for more info, there are lots of links from here:
http://msdn.microsoft.com/en-us/libr...tionscope.aspx
[don't ask me why it has the same VB example twice, yet no C#]

Alternatively, just use your favorite search engine...

Marc
Jun 27 '08 #4

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

Similar topics

1
1243
by: ILLOGIC | last post by:
Hello, i am beginner in c++. I hope tobe sufficiently clear and that someone could help me on this topic. For example i have template function <typename T> T sin_func(T & x){return sin(x);} could it be possible that the paramenter of the function is another template function? An example would be very helpful
7
2498
by: Steven T. Hatton | last post by:
I am trying to convert some basic OpenGL code to an OO form. This is the C version of the program: http://www.opengl.org/resources/code/basics/redbook/double.c You can see what my current effort at converting that code to an OO form looks like in the code listed below. The problem I'm running into is that the OpenGL functions that take the names of other functions as arguments don't like the way I'm passing the member functions of my...
3
2287
by: Steven Taylor | last post by:
Hope someone can assist. I'm trying to answer a book question. I'm going around in circles in relation to 'pointer-to-char'. Object : A short program is to be created, which involves a structore and one member element is a char array. A function is to be created that passes the structure as a reference, along with the 'pointer-to-char'. The function is to assign the passed-in 'pointer-to-char' to the referenced (passed-in)...
6
4025
by: Melkor Ainur | last post by:
Hello, I'm attempting to build an interpreter for a pascal-like language. Currently, I don't generate any assembly. Instead, I just build an abstract syntax tree representing what I've parsed from a user's program and use a C backend to evaluate the tree. I'm using Lex, Yacc and C. Now, there are some functions that are built into this language and others which are not. The problem I'm having is that I haven't found a way to represent...
3
1925
by: IntraRELY | last post by:
I have the following function, Notice how I am passing the dateInterval as a string. What is the correct way to pass "DateInterval.Year" as a variable to a function? TIA, Steve Wofford www.IntraRELY.com
11
4436
by: cps | last post by:
Hi, I'm a C programmer taking my first steps into the world of C++. I'm currently developing a C++ 3D graphics application using GLUT (OpenGL Utility Toolkit written in C) for the GUI components. The application is built around a "World" object that contains a "GUI" object that is a C++ wrapper around GLUT. What I'd like to do is pass a pointer to a member function in the World class to function in the GUI
5
5026
by: sfeher | last post by:
Hi All, I need to call a function(loaded with appendChild) for which I have the name as a string. .... var fnName = 'fn1'; var call = fnName + '('+ param +' )'; eval(call);
3
1366
by: waheed azad | last post by:
Hi, I have a been developing an accounting system for a non-profit organization. I had decided to to divide the solution, in three layers, presentation, business layer and database layer. My business layer is composed of objects like Account, Transaction, Voucher etc. And my database layer is composed of objects like AccountDB, TransactionDB, VoucherDB. Now each of my layer is residing in a seperate project under the same solution....
0
9734
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9607
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10665
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10406
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10420
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9221
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5568
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5704
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3029
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.