on 04-06-2005 5:48 PM
The Question : Can DI Run Under COM+ Distributed transaction
I'm newbie ( Sorry )
I Have COM+ Application
With Call Across Multiple Component in another Process ( dllhost.exe )
Can I Use DI api In safe Transaction Mode To read Or modify SAP One Data
Is it Possible ?
Sample , and Guideline are appreciated
Thanks
Hi Michele,
There's a new method + a new property in the company object (release in patch 09 of version 2004):
Method <b>IsDTCTransactionObjectSet()</b> will tell you whether or not such an object is set.
The property <b>DTCTransactionObject</b> takes or returns a pointer to the ITransaction interface.
2.1 When you set the pointer, a check whether or not it is a valid ITransaction pointer is performed.
2.1.1 Then DI API checks the isolation level of the object and throws an exception, if it is not ISOLATIONLEVEL_ISOLATED.
2.1.2 SQLSetConnectOption gets called with SQL_ATTR_ENLIST_IN_DTC.
2.1.3 If you set DTCTransactionObject to "null", enlistment will be ended:
SQLSetConnectOption gets called with SQL_ATTR_ENLIST_IN_DTC and subsequently with ..., SQL_TXN_ISOLATION, SQL_TXN_READ_COMMITTED.
There's no sample yet.
I hope the information above is explicit enough so that you don't need a guideline?
HTH,
Frank
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Many thanks, Me excuses for the delay, I have appreciated your answer.
>> Can DI API Work Under COM+ transaction
If it has a second in more I would wish to understand if The property DTCTransactionObject goes used in the way illustrated in the following example:
[code]'This Function IS called In a Component
'registered in A Com+ Transaction
'marked as require new Transaction or require transaction
Public Sub DoSomeWork(ByVal someParameter$)
On Error GoTo err_handler
Dim vCompany
Set vCompany = CreateObject("SAPbobsCOM.Company")
'<b>It's OK this before any call ??</b>
Set vCompany.DTCTransactionObject = COMSVCSLib.GetObjectContext
'Initialize the Company Object for the Connect method
vCompany.Server = "(local)"
vCompany.CompanyDB = "SBODemo_US"
vCompany.UserName = "manager"
vCompany.Password = "manager"
Dim nResult As Long
Dim strErrString As String
'Connect to the database
nResult = vCompany.Connect
If nResult <> S_OK Then Err.Raise vbObjectError + E_MAX_CRIT_ERR, , "Cannot connect to SB1"
'perform some operation read and or write on Company Object
PerformOperation vCompany, someParameter
'..........
'release object <b>( Connection POOL Work ?? ) </b>
vCompany.Disconnect
Set vCompany = Nothing
If Not ConditionIsMeet() Then
'Is all Transaction Rolled Back ???
'Note not StartTransaction of vCompany is called
Err.Raise vbObjectError + E_MIN_EXCLAMATIO_ERR, , " .... message ...."
'...........
End If
'another com+ Component in same transaction
Dim otherComponent
Set otherComponent = CreateObject("ServiceNotification.SendMail")
otherComponent.Notify someParameter
'' Clean Up
'HRESULT 0 , Implicit Commit
Exit Sub
err_handler:
Dim ee As ERR_FRAME
ee = PushErr()
'' clean up
'' ...............
PopErr ee 'rollback
End Sub
[/code]
Re
'<b>It's OK this before any call ??</b>
Set vCompany.DTCTransactionObject = COMSVCSLib.GetObjectContext
No, asfaik, SQLSetConnectOption (see 2.1.2 SQLSetConnectOption) needs an existing connection.
I think the same applies to any other operation, but I am not sure as I did not check it out myself; I just once heard from a partner that "it works"...
Sorry for the XXlate reply! Did you try more in the meantime?
Regards,
Frank
Many thanks Frank.
For the collaboration and the gentility.
I will make to know...
The steps that I must make are therefore:
'Connect to the database
nResult = vCompany.Connect
If nResult <> S_OK Then Err.Raise vbObjectError + E_MAX_CRIT_ERR, , "Cannot connect to SB1"
Set vCompany.DTCTransactionObject = COMSVCSLib.GetObjectContext
'.....
'Work
'.............
Set vCompany.DTCTransactionObject = Nothing
Regards ,
Michele
User | Count |
---|---|
107 | |
12 | |
11 | |
6 | |
5 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.