Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

2 phase commit

Status
Not open for further replies.

tapks

IS-IT--Management
Sep 6, 2001
72
IN
HI!

Can any body tell me how to do 'two phase commit' with MTS under MS-Windows 2000 Prof?

Thanks in advance.

Tapks
 
Dear Tapks
two phase commit is handled automatically by the combination of MSDTC and COM+ u don't have to write extra code for it if u have devloped a COM+ component which can did tasks on a single Back-end server then it can do it for multiple servers
i think u know what 'two phase commit' means actually its termonlagy in which MSDTC handles transaction for dispersed back-end servers,more than 1 server..
Regards
Nouman
 
Hi Nouman!

Thanks a lot. Can u please let me know how to implement the same in Visual Basic?

The problem is :
There are 2 database servers & my COM object is in my Pc & all re connected in LAN. I want to insert recoreds in the database of both server at the saem time. If any one fails I wnat to roll back the other one. How to do this in VB6 under Win 2000?

Pl help me out.

Tapks
 
dear tapks
okay i am posting a snippet of code which help u out
u don't have to worry about the 2 databse it will be done by MSDTC and Components Service and code of 'SetAbort' and 'SetCOmmit' ,'SetAbort' for aborting the whole transaction no matter if it is inserting in 2 differnt databse servers and 'SetComplete' will do a safe atomic transaction i hope u got it..here is the code
On Error GoTo ErrH


Dim objDOCodes As New clsDOCodes
Dim ObjContext As ObjectContext

Set ObjContext = GetObjectContext()
'Do what ever code for ur insertion in the lines below
'i am pasting some dummy code for ur ease

Dim objCmdTask As New ADODB.Command


With objCmdTask
.CommandType = adCmdStoredProc
Set .ActiveConnection = DBConnection(varInfo (INT_CONNECTSTRING))
.CommandText = STR_STP_ORD_INSERT_TASK

.Parameters.Append .CreateParameter (STR_PRM_ORD_TASKREMINDER_DESC, adVarChar, adParamInput, 255, mstrTaskDescription)
.Execute

End With

ObjContext.SetComplete
Exit Function
ErrH:
ObjContext.SetAbort
Err.Raise Err.Number, Err.Source, Err.Description


Hope the above code will help u
but if u still have some q i am here
Regards
Nouman
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top