Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Component Services / March 2004

Tip: Looking for answers? Try searching our database.

Transaction error...Either enlist this session in a new transaction or the NULL transaction

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
bobben - 23 Feb 2004 11:57 GMT
I am doing some database work, nothing fancy, just creating som new rows and
stuff.  When I get this error.

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

Exception Details: System.Data.SqlClient.SqlException: Distributed
transaction completed. Either enlist this session in a new transaction or
the NULL transaction

When I remove the ServicedComponent inheritance from my Business class
everything works great!

To ellaborate:

I have an abstract  Class A  which inherits from SerivcedComponetns and also
implement an Execute method, in which SubExecute is called (implemented by
class B)

Class B inherits class B and Implements SubExecute.

Both methods are tagged with [AutoComplete], and bot classes are tagged with
[Serializable] and [ Transaction(TransactionOption.Required) ]

But when any Database operations (implemented in separate layer) are called
it returns with an error!

Anybody got an idea of why

Thanks a lot!

B?rge
bobben - 23 Feb 2004 12:29 GMT
I have to add that several of my database functions (both the C# code and
the stored procedures) calls Begin Transaction. Is this a problem?

Thanks!

> I am doing some database work, nothing fancy, just creating som new rows and
> stuff.  When I get this error.
[quoted text clipped - 28 lines]
>
> B?rge
Mark Jen [MSFT] - 23 Feb 2004 23:45 GMT
Hi Bobben,

If I'm reading this correct, you have something like this:

[Transaction(TransactionOption.Required)]
public class A : ServicedComponent
{
   [AutoComplete]
   void Execute() {
       SubExecute();
   }

   protected virtual SubExecute() { }
}

[Transaction(TransactionOption.Required)]
public class B : A {
   [AutoComplete]
   void SubExecute() {
       // do work
   }
}

In this case, if you create an instance of class B and call Execute, I think
that will happen is this:

1. Base class A's Execute will be called. Since TransactionOption.Required
is specified, a transaction will be created.
2. B.SubExecute will be called. Since there is already a transaction, it
will be used for the execution of SubExecute
3. Upon returning from B.SubExecute, AutoComplete will commit the
transaction.
4. Returning from A.Execute will also try to commit the transaction,
yielding the error you are seeing.

Also, if you remove the inheritance from ServicedComponent, I don't think a
transaction will actually get created in the background through COM+.

HTH,
Mark Jen [MSFT]
Signature

Please reply in newsgroup.
This posting is provided "AS IS" with no warranties, and confers no rights.

> I have to add that several of my database functions (both the C# code and
> the stored procedures) calls Begin Transaction. Is this a problem?
[quoted text clipped - 37 lines]
> >
> > B?rge
Mark Jen [MSFT] - 24 Feb 2004 00:07 GMT
Also, calling BeginTransaction and/or using a "begin transaction" in TSQL
shouldn't cause a problem. AFAIK, those calls make a SQL local database
transaction which should then be automatically enlisted in the distributed
transaction if one exists. Thus, the outcome of the local transaction should
be dependent on the distributed transaction.

Thanks,
Mark Jen [MSFT]
Signature

Please reply in newsgroup.
This posting is provided "AS IS" with no warranties, and confers no rights.

> Hi Bobben,
>
[quoted text clipped - 79 lines]
> > >
> > > B?rge
bobben - 05 Mar 2004 11:03 GMT
Thanks for your input.

I aggree with you in the way you described it.
But in B::SubExecute() i call another assembly (which is not registered with
Com+) which in turn does the actual db work.
Could this be the problem?

B?rge

> Also, calling BeginTransaction and/or using a "begin transaction" in TSQL
> shouldn't cause a problem. AFAIK, those calls make a SQL local database
[quoted text clipped - 96 lines]
> > > >
> > > > B?rge
Florin Lazar [MSFT] - 10 Mar 2004 08:53 GMT
Hi,

Can you include the stack of the exception? At what step in your sequence of
actions do you get the exception?

Regards,
Signature

Florin Lazar - Microsoft - [ http://blogs.msdn.com/florinlazar ]
Please do not send email directly to this alias. This alias is for newsgroup
purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.

> I am doing some database work, nothing fancy, just creating som new rows and
> stuff.  When I get this error.
[quoted text clipped - 28 lines]
>
> B?rge

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.