Transactions in MS Access
Let's say I have the following code in a form that fires on some click event.
DoCmd.SetWarnings False
DoCmd.OpenQuery "AddSomeStuff"
DoCmd.OpenQuery "UpdateSomeOtherStuff"
DoCmd.OpenQuery "DeleteABunchOfCrap"
DoCmd.SetWarnings True
Is it safe to assume that the three update queries you executed (in SQL Server) are not transactional in that they run, are they separate transactions?
+2
a source to share
2 answers
Transactions can have access if needed, but you are correct in your code, each transaction will execute on its own. Anyway, here's a small sample code
Public Sub Foo()
Dim wrk As Workspace
Dim db As DAO.Database
On Error GoTo Error_trap
Set wrk = DBEngine(0)(0)
Set db = wrk.OpenDatabase("mydb.mdb")
wrk.BeginTrans
db.Execute "AddStuff"
db.Execute "DeleteStuff"
db.Execute "UpdateStuff"
wrk.CommitTrans
db.Close
wrk.Close
Set db = Nothing
wt wrk = Nothing
Exit Sub
Error_trap:
wrk.Rollback
MsgBox "Something went wrong!"
End Sub
0
a source to share