Platform SDK: Transaction Server |
Update Method, Step7 (Visual Basic)
[This product will work only on Windows NT 4.0 versions and earlier. For Windows 2000 and later, see COM+ (Component Services).]
Public Function Update() As Long On Error GoTo ErrorHandler ' get result set and then update table ' with new receipt number Dim adoConn As New ADODB.Connection Dim adoRsReceipt As ADODB.Recordset Dim lngNextReceipt As Long Dim strSQL As String strSQL = "Update Receipt set NextReceipt = NextReceipt + 100" adoConn.Open strConnect ' Assume that if there is an ado error then ' the receipt table does not exist On Error GoTo ErrorCreateTable TryAgain: adoConn.Execute strSQL strSQL = "Select NextReceipt from Receipt" Set adoRsReceipt = adoConn.Execute(strSQL) lngNextReceipt = adoRsReceipt!NextReceipt Set adoConn = Nothing Set adoRsReceipt = Nothing ' we are finished and happy GetObjectContext.SetComplete Update = lngNextReceipt Exit Function ErrorCreateTable: On Error GoTo ErrorHandler ' create the receipt table Dim objCreateTable As CreateTable Set objCreateTable = CreateObject("Bank.CreateTable") objCreateTable.CreateReceipt GoTo TryAgain ErrorHandler: If Not adoConn Is Nothing Then Set adoConn = Nothing End If If Not adoRsReceipt Is Nothing Then Set adoRsReceipt = Nothing End If GetObjectContext.SetAbort ' we are unhappy Update = -1 ' indicate that an error occured Err.Raise Err.Number, "Bank.UpdateReceipt.Update", Err.Description End Function