用事务处理实现!Dim cn As New ADODB.Connection Dim rs As New ADODB.Recordset. . . ' Open connection. cn.Open' Open titles table. rs.Open "SELECT * FROM titles", Cn, adOpenDynamic, adLockPessimistic . . . ' Begin the transaction. rs.MoveFirst cn.BeginTrans' User loops through the recordset making changes. . . . ' Ask if the user wants to commit all the changes made. If MsgBox("Save all changes?", vbYesNo) = vbYes Then cn.CommitTrans Else cn.RollbackTrans End If
具体一点的?
Dim rs As New ADODB.Recordset. . .
' Open connection.
cn.Open' Open titles table.
rs.Open "SELECT * FROM titles", Cn, adOpenDynamic, adLockPessimistic
. . .
' Begin the transaction.
rs.MoveFirst
cn.BeginTrans' User loops through the recordset making changes.
. . .
' Ask if the user wants to commit all the changes made.
If MsgBox("Save all changes?", vbYesNo) = vbYes Then
cn.CommitTrans
Else
cn.RollbackTrans
End If