Solved

ContextUtil class and com

Posted on 2004-10-07
3
239 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
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
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…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

758 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now