开发者

transactions in MS Access

Let's say I have the following code in a form that is triggered on some click event.

DoCmd.SetWarnings Fals开发者_运维知识库e
DoCmd.OpenQuery "AddSomeStuff"
DoCmd.OpenQuery "UpdateSomeOtherStuff"
DoCmd.OpenQuery "DeleteABunchOfCrap"
DoCmd.SetWarnings True

Can I assume that the three update queries I executed (in SQL Server) are not transactional in that they are run is separate transactions?


Yes, they will run in separate transactions.


Access can have transactions if needed however you are right in your code each transaction would be executed on its own. Anyway here is a little code sample

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜