Έαν έχεις ένα κεντρικό ναι, ή θα το βάλεις στο σημείο που ελέγχεις τα λάθη από το transaction εαν έχεις δύο παγίδες λαθών δες παρακατω
Dim myConnection As ADODB.Connection
Dim myRecordset As ADODB.Recordset
Set myConnection = New ADODB.Connection
Set myRecordset = New ADODB.Recordset
myConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.3.51;Data Source=c:\BegDB\Biblio.mdb"
'—Open the connection --
myConnection.Open
'Determine if we conected.
If myConnection.State = adStateOpen Then
myRecordset.Open "SELECT * FROM TITLES", myConnection, _
adOpenDynamic, adLockOptimistic, adCmdTable
Else
MsgBox "The connection could not be made."
myConnection.Close
Exit Sub
End If
'—just to be sure --
myRecordset.MoveFirst
On Error GoTo transError
'—here is the top of the transaction sandwich --
myConnection.BeginTrans
While Not myRecordset.EOF
mcounter = mcounter + 1
myRecordset!Title = myRecordset!Title & "" 'so we don't really change it
myRecordset.Update
myRecordset.MoveNext
Wend
'—if we got here ok, then everything is written at once
myConnection.CommitTrans
myRecordset.Close
myConnection.Close
Exit Sub
transError:
myConnection.RollBack
myRecordset.Close
myConnection.Close
MsgBox Err.Description
Antonios Chatzipavlis