Public Sub()
Connection conn = New ADODB.Connection
Command cmd = New ADODB.Command;
Recordset rs = New ADODB.Recordset
' Step 1
conn.Open "DSN=pubs;uid=sa;pwd=;database=pubs"
' Step 2
cmd.CommandText = "SELECT * from authors"
' Step 3
rs.Open cmd, conn, adOpenDymanic, adLockBatchOptimistic
' Step 4
rs!au_lname.Optimize = TRUE
rs.Sort = "au_lname ASCENDING"
rs.Filter = "phone LIKE '415 5*'"
rs.MoveFirst
Do While Not rs.EOF
Debug.Print "Name: " & rs!au_fname & " " rs!au_lname & _
"Phone: " rs!phone & vbCr
rs!phone = "777" & Mid(rs!phone, 5, 11)
rs.MoveNext
Loop
' Step 5
conn.BeginTrans
'Step 6, part 1
rs.UpdateBatch
conn.CommitTrans
'Step 6, part 2
On Error
rs.Filter = adFilterConflictingRecords
rs.MoveFirst
Do While Not rs.EOF
Debug.Print "Conflict: Name: " & rs!au_fname " " & rs!au_lname
rs.MoveNext
Loop
conn.Rollback
Resume Next
End Sub
This is the end of the Visual Basic tutorial.