Databases Reference
In-Depth Information
' Create an SQL UPDATE statement
' to raise prices by 10%
strSQL = "UPDATE BOOKS SET Price = Price*1.1
' Create a new QueryDef object
Set qdf = db.CreateQueryDef("PriceInc", strSQL)
' Begin a transaction
ws.BeginTrans
' Execute the query
qdf.Execute
' Check the number of records affected and either roll back transaction
or proceed
If qdf.RecordsAffected <= 15 Then
MsgBox qdf.RecordsAffected & " records affected " & _
"by this query. Transaction cancelled."
ws.Rollback
Else
MsgBox qdf.RecordsAffected & " records affected " & _
"by this query. Transaction completed."
ws.CommitTrans
End If
End Sub
Search WWH ::




Custom Search