Solved

ContextUtil class and com

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

717 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