Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2004-03-22
9
Medium Priority
?
1,254 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
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
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…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

598 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