?
Solved

Distributed transaction completed. Either enlist this session in a new transaction ..

Posted on 2004-03-22
9
Medium Priority
?
1,230 Views
Last Modified: 2010-05-18
Hi,

I have an mts object written in vb, named A. Its transaction mode is 'required transaction' A calls an object named B with mode 'uses transaction'. B calls a data access component C which accesses the database. C also has a mode of  'uses
transaction'. The number of calls to B from A are large.

I keep getting this error, after a method in object A is called:

"Distributed transaction completed. Either enlist this session in a new transaction or the NULL transaction."

I want to understand how and why this error comes up. I am not accessing distributed databases. IS this error saying that the transaction has already committed, and another database access is trying to commit the transaction again?

Do we have to encapsulate every write to the database with a
transaction, or can we combine a number of writes into one transaction, as I am doing?

Thanks!




0
Comment
Question by:reader
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
9 Comments
 
LVL 23

Expert Comment

by:Snarf0001
ID: 10648784
You can definately enlist multiple writes into the same transaction, this is the primary reason for using them.  It sounds like either A or B is committing or rolling back the transaction before the next component can use it.

Make sure you are actually calling the BeginTrans method in object A, if not an implicit transaction will be created (and committed) with every call to the db.
Also double check all of the code, and make sure you are not committing or rolling it back in A or B and then calling another component.

Lastly, ensure you are instantiating B and C with the CreateInstance method of the ObjectContext.  If created with any other method (new, CreateObject...) the objects will be created and will function normally, but will not be able to take part in the same transaction.

Hope this is of some help.
0
 

Author Comment

by:reader
ID: 10652098
How should I call the BeginTrans method in object A? Since
its transaction mode is 'required transaction', A is enlisted in an implicit transacion I believe.

My question is: should I use explicit transactions with the TransactionContextObject, since A does not have any method called BeginTrans ..? Where do i get this BeginTrans method?
0
 
LVL 23

Expert Comment

by:Snarf0001
ID: 10652318
My apologies, upon reading again my comment was horribly unclear.

The BeginTrans would be called on the database connection object, but is required for DB transaction ONLY (without MTS).  MTS does start and carry over implicit transactions itself, including calls to the database.

Object B must then be initialized as follows:

Dim ctxObject As ObjectContext
Dim objAccount As {ObjB.ProgID}

Set ctxObject = GetObjectContext()

Set objAccount =  ctxObject.CreateInstance("{ObjB.ProgID}")

and C must be initialized the same way.  
Neither A or B should then be calling SetCommit() or SetAbort() if further objects are going to be initialized AFTER that.

Sorry for the confusion.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:reader
ID: 10652439
That is exactly what I've been doing, and I still don't know why I am getting that error!
0
 
LVL 23

Expert Comment

by:Snarf0001
ID: 10652503
At what point in the code are you committing (or aborting) the transaction?

What exactly is the sequence that these objects go through?  You mentioned that calls between A and B were numerous.  Does A make calls to B at different times and intervals depeding on other code or is it a strict sequence of calls one after the other?
0
 

Author Comment

by:reader
ID: 10654192
The asp page calls A. A calls B a number of times. B calls C a number of times. The transaction should start in A, and end in A (finally).

Can the error be the result of an incorrect SQL call, rather than the reason of the SQL call not executing?

The interesting this is that when I made the mode of A 'not an MTS object', even then the transactionseemed to start, and I got the same error ..
0
 
LVL 23

Expert Comment

by:Snarf0001
ID: 10657431
That is possible.  If there was sql error occured, that would cause the entire transaction to rollback and terminate there.
0
 

Accepted Solution

by:
PashaMod earned 0 total points
ID: 11023283
PAQed, with points refunded (500)

PashaMod
Community Support Moderator
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently, Microsoft released a best-practice guide for securing Active Directory. It's a whopping 300+ pages long. Those of us tasked with securing our company’s databases and systems would, ideally, have time to devote to learning the ins and outs…
In this article, we’ll look at how to deploy ProxySQL.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question