Hi Mike,
Is there a way to create the scenario with a group of business objects such as a list of orders that if one fails to save they would all get rolled back?
Dim weStartedTransaction As Boolean
With Manager.Database
Try
If .SQLTransaction Is Nothing Then
' flag that we created the transaction, so we know if we should be the ones to .commit or .rollback later.
.BeginNewTransaction()
weStartedTransaction = True
End If
'Your goes code here, perhaps a for loop over a list of objects, calling myObject.Save for each one.
If weStartedTransaction Then
.SQLTransaction.Commit()
.SQLTransaction.Dispose()
.SQLTransaction = Nothing
End If
Catch ex As Exception
If weStartedTransaction AndAlso .SQLTransaction IsNot Nothing Then
If .SQLTransaction.Connection IsNot Nothing Then
.SQLTransaction.Rollback()
End If
.SQLTransaction.Dispose()
.SQLTransaction = Nothing
End If
'Maybe a messagebox or a Throw goes here, plus any other code you need to deal with the error condition (ie. set status properties or whatever).
Finally
If weStartedTransaction Then
.SQLTransaction = Nothing
End If
End Try
End With
Return to Technical and or Programming
Users browsing this forum: No registered users and 12 guests