aspx thread: Re: Question about Transactions and Connection pooling.
NGWS SDK Documentation -> NGWS SDK Developer Specifications -> Using COM+
1.0 Services from Managed Code Whitepaper
As for transactions in VB7:
Here is a VB7 code sample.
imports System
imports Microsoft.ComServices
imports System.Runtime.InteropServices
imports ADODB
imports ACCOUNTCom
imports Microsoft.VisualBasic
option strict off
namespace VB7Bank
public class <ComEmulateAttribute("VB7Bank.AccountInternal"), _
GuidAttribute("869DD7AE-62B6-45ed-B999-0702A7702B28"), _
TransactionAttribute(TransactionOption.Required)> _
Account
end class
public class <ComVisible(false)> AccountInternal
implements IAccount
private const strConnect = "FILEDSN=BankSample"
public function Post(ByVal lngAccountNo As Integer, ByVal
lngAmount As Integer) As String Implements IAccount.Post
dim strResult as String
dim adoRS as ADODB._RecordSet
dim adoConn as ADODB.__Connection
dim bSuccess as boolean
bSuccess = false
try
' check for security
if (lngAmount > 500 or lngAmount < -500)
then
if not
ContextUtil.IsCallerInRole("Managers") then
throw new Exception("Need
'Managers' role for amounts over $500")
end if
end if
dim varRows As Object
dim strSQL As String
varRows = new Object()
adoConn = new __Connection()
adoConn.Open(strConnect)
TryAgain:
try
strSQL = "UPDATE Account SET Balance
Balance + " & lngAmount & _
" WHERE AccountNo = " &
lngAccountNo
adoConn.Execute( strSQL, varRows,
128)
catch e as exception
dim ct As ICreateTable
ct = new CreateTable
ct.CreateAccount()
goto TryAgain
end try
' get resulting balance which may have been
further updated via triggers
strSQL = "SELECT Balance FROM Account WHERE
AccountNo = " & lngAccountNo
adoRS = adoConn.Execute( strSQL, varRows,
-1)
dim intBalance as integer
intBalance
cint(adoRS.Fields("Balance").Value)
' check if account is overdrawn
if (intBalance) < 0 then
throw new Exception("Error. Account
" + Str$(lngAccountNo) + " would be overdrawn by " + Str$(intBalance) + ".
Balance is still " + Str$(intBalance - lngAmount) + ".")
else
if lngAmount < 0 then
strResult = strResult &
"Debit from account " & lngAccountNo & ", "
else
strResult = strResult &
"Credit to account " & lngAccountNo & ", "
end if
strResult = strResult + "balance is
$" + intBalance.ToString() + " (VB7)"
end if
bSuccess = true
finally
if bSuccess then
ContextUtil.SetComplete()
post = strResult
else
ContextUtil.SetAbort()
post = "Failed"
end if
end try
end function
end class
end namespace