472,955 Members | 2,437 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Re: WCF & Transactions

Hello,

I have one BLL object X with method Y. Inside method Y (*) I call
DAL object(s).

Operation Y can include more then one DAL object (dalObj1.Write,
dalObj2.Write) so I create some kind of "token" with sql connection
reference and pass it to DAL object(s) involved in operation Y (**).

At some point in time (ambient) transaction will finish (with success or
failure) and emit TransactionCompleted event.

I am asking if I can grab that token reference with sqlconnection
reference in TransactionCompleted eventhandler and close connection
without side effects and problems?
(*) call(s) to DAL object(s) is/are inside transaction scope which is
configured to use ambient transaction

(**) I know that it is possible to write this code with "(using
SqlConnection) { write db }" inside each DAL object write method and
don't bother with connection closing problem but this will result in
distributed transaction (because I open N connections to the same SQL
server). Am I correct?

I hope explanation is better this time :)
Alvin Bruney [ASP.NET MVP] wrote:
Sorry for misunderstanding you. I don't understand what you are doing.
You seem to be sharing one connection object with clients as opposed to
object pooling a connection object among clients. There's a huge
difference here if I've understood you correctly. I don't know what the
behavior would be at this point.

To your design point, you shouldn't be passing opened connection around
because you place the closing responsibility on the caller - caller
doesn't have to honor it which implies a resource leak. The better
pattern is to grab the data from the connection, close the connection,
and return the data in a custom business object inside your DAL. There's
no possibility of a resource leak in that pattern.
Jun 27 '08 #1
1 1364
You can do it this way, bear in mind that, according to the docs, your way
of hooking up to transactioncompleted events cause performance issues.

--

Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The O.W.C. Black Book, 2nd Edition
Exclusively on www.lulu.com/owc $19.99
-------------------------------------------------------
"No Name" <my************@mail.comwrote in message
news:#m**************@TK2MSFTNGP04.phx.gbl...
Hello,

I have one BLL object X with method Y. Inside method Y (*) I call
DAL object(s).

Operation Y can include more then one DAL object (dalObj1.Write,
dalObj2.Write) so I create some kind of "token" with sql connection
reference and pass it to DAL object(s) involved in operation Y (**).

At some point in time (ambient) transaction will finish (with success or
failure) and emit TransactionCompleted event.

I am asking if I can grab that token reference with sqlconnection
reference in TransactionCompleted eventhandler and close connection
without side effects and problems?
(*) call(s) to DAL object(s) is/are inside transaction scope which is
configured to use ambient transaction

(**) I know that it is possible to write this code with "(using
SqlConnection) { write db }" inside each DAL object write method and don't
bother with connection closing problem but this will result in distributed
transaction (because I open N connections to the same SQL server). Am I
correct?

I hope explanation is better this time :)
Alvin Bruney [ASP.NET MVP] wrote:
>Sorry for misunderstanding you. I don't understand what you are doing.
You seem to be sharing one connection object with clients as opposed to
object pooling a connection object among clients. There's a huge
difference here if I've understood you correctly. I don't know what the
behavior would be at this point.

To your design point, you shouldn't be passing opened connection around
because you place the closing responsibility on the caller - caller
doesn't have to honor it which implies a resource leak. The better
pattern is to grab the data from the connection, close the connection,
and return the data in a custom business object inside your DAL. There's
no possibility of a resource leak in that pattern.
Jun 27 '08 #2

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

Similar topics

1
by: Alexander Ross | last post by:
Lets say I want to execute 3 postgresql queries in a row based on the inputs in a php form...Here's the catch though. What happens if #1 and #2 execute perfectly, but #3 fails for one reason or...
4
by: Leaf | last post by:
Greetings, I've been reading with interest the threads here on deadlocking, as I'm finding my formerly happy app in a production environment suddenly deadlocking left and right. It started...
5
by: princevejita1 | last post by:
Hello I have problem with my MySQL server and transactions. I installed MySQL server 5.0.11 with MySQL administrator & MySql Query Browser on Win XP Prof. I would like to use transactions, so I...
7
by: simon | last post by:
Hi I know this has been done to death....but obviously at some point in the dim and distant past! I wish to program a retail database for my shop, I have trawled many forums and I only manage...
9
by: Greg Gursky | last post by:
Hello: I'm doing some planning on a potential project with which I need some help. The database at the focus of this question is a MS Access database that is currently accessed by DAO from a...
1
by: Jim Bancroft | last post by:
Hi everyone, I'm running into a problem with my ASP.Net application. I've just created a new aspx page which uses some new components of mine that inherit from ServicedComponent and are...
3
by: Lada 'Ray' Lostak | last post by:
Hello ppl, Imagine some online system, based on PgSql. There are 'many' parts which depends on each other. I will give small example, but instead of simple table imagine changing tenths various...
16
by: ARC | last post by:
Hello all, So I'm knee deep in this import utility program, and am coming up with all sorts of "gotcha's!". 1st off. On a "Find Duplicates Query", does anyone have a good solution for...
0
by: Vinod Sadanandan | last post by:
STANDBY DATABASE MONITORING & PROTECION MODES (9iR2) This document is written for understanding and monitoring standby database configured with diffrent protection modes . MAXIMUM PROTECTION ...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
1
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.