Solved

ContextUtil class and com

Posted on 2004-10-07
3
251 Views
Last Modified: 2008-02-01
I was wondering is there a way to do transactions in .net

I was at a microsoft .net seminar and asked them doing transactions like com+ but not actully using com services

the reason why is the database is mysql.  They said use the distributor transaction coordinator class.

If you have an example in how to do this it would be greatly appreciated.


0
Comment
Question by:genesisproject
[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
3 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 12253317
Are you talking about transactions in ADO.NET?

Bob
0
 
LVL 10

Accepted Solution

by:
123654789987 earned 500 total points
ID: 12256752
Try the following link

The Distributed Transaction Coordinator (DTC) is the Transaction Processing monitor for Microsoft Windows 2000.


http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/bdadotnettransact1.asp

Also see this explanation:

The COM+ BYOT feature allows COM+ components to set a preexisting Microsoft Distributed Transaction Coordinator (DTC) or Transaction Internet Protocol (TIP) transaction as the transaction property of a new component's context. This allows COM+ components to be associated with transactions whose lifetimes are controlled by a transaction processing monitor, object transaction service, or database management system. BYOT is also useful in integrating with transactions coordinated by TIP.

Note   Automatic transactions, rather than BYOT transactions, are the preferred programming model for writing business components. BYOT transactions must be used with caution. In certain situations, they can result in a transaction spanning multiple synchronization domains (that is, allowing parallelism with a transaction).
The BYOT class exposes two methods: CreateWithTransaction and CreateWithTipTransaction. The following example shows how to create an object that uses the transaction from another object.

BYOT Demonstration

[Visual Basic]
Imports System
Imports System.Reflection
Imports System.EnterpriseServices

<assembly: AssemblyKeyFile("BYOTDemo.snk")>

Public Class Base
      Inherits ServicedComponent
      Public Readonly Property Transaction() as Object
        Get
            Return ContextUtil.Transaction
        End Get
      End Property
End Class

<Transaction()> Public Class CTransaction1
Inherits Base
' Insert your transaction logic here.
End Class

<Transaction()> Public Class CTransaction2
Inherits Base
' Insert your transaction logic here.
End Class

Class BYOTDemonstration
      Public Shared Sub Main()
            ' Create a transactional object, and then get its
            ' transaction.
            Dim tx1 as New CTransaction1
            Console.WriteLine("Created transaction1.")
            Dim tx as Object = tx1.Transaction
            Console.WriteLine("Got the transaction of transaction1.")      
            Dim tx2 as CTransaction2 = ctype(BYOT.CreateWithTransaction(tx, _ gettype(CTransaction2)),CTransaction2)
            Console.WriteLine("Created transaction2 with the _
            transaction of transaction1.")
            End Sub
End Class
0
 

Author Comment

by:genesisproject
ID: 12290622
thanks for the quick response so with byot how would I do a simple transaction like this
'this would be in my business logic

Dim client as new Demo.Client
Dim guardian as New Demo.Guardian

the client and guardian class are my calls to the database Data Access Layer



this is the transaction part


  client.AddClient(addData.Tables(0).Row(0))

guardian.addGuardian(addData.Tables(0).Row(0))






0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
"Emulate" TAB key when press Enter Key 3 91
Set arraylist as datatable 2 28
Best book for Internet security 4 49
sql server connection string in config file 4 37
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…

738 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