Solved

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

Posted on 2004-03-22
9
1,203 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 is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

As technology users and professionals, we’re always learning. Our universal interest in advancing our knowledge of the trade is unmatched by most industries. It’s a curiosity that makes sense, given the climate of change. Within that, there lies a…
Recently I was talking with Tim Sharp, one of my colleagues from our Technical Account Manager team about MongoDB’s scalability. While doing some quick training with some of the Percona team, Tim brought something to my attention...
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

729 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