The BeginTransaction articles also have examples, but I noticed some inefficiencies in the code (like assigning the connection object to the command object twice). I just tested this quick hack on an XP SP2 system with Office 2000 installed. It ran fine against an Access 97 format database:
Module Module1
Sub Main()
Dim dbsrc As New OleDb.OleDbConnection(String.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Jet OLEDB:Database Password=foo", "filename.mdb")
Dim cmd As OleDb.OleDbCommand
Dim trans As OleDb.OleDbTransaction
Dim act As String = ""
Dim lcv As Integer
Try
act = "opening database"
dbsrc.Open()
act = "create command object"
cmd = dbsrc.CreateCommand
act = "create transaction"
trans = dbsrc.BeginTransaction
act = "assign transaction to command"
cmd.Transaction = trans
act = "add some data"
For lcv = 1000 To 1010
cmd.CommandType = CommandType.Text
cmd.CommandText = String.Format("INSERT INTO comArea (Area) VALUES ('{0}')", lcv)
cmd.ExecuteNonQuery()
Next
act = "roll back transaction"
trans.Rollback()
act = "dispose trans"
trans.Dispose()
act = "dispose cmd"
cmd.Dispose()
act = "closing database"
dbsrc.Close()
dbsrc.Dispose()
Catch ex As Exception
Console.WriteLine("Error " & act & vbCrLf & ex.ToString)
End Try
Console.ReadKey() 'So you can see the screen to read messages
End Sub
End Module
To use this example, create a new project and select a console application. Then replace all the code in the module1.vb file with the above code. Change the connection string to something appropriate (i.e., the database path and filename) and change the SQL statement's table and field name. Then run it. By default, this will roll back the transaction so it does not actually make any changes to the target table. Use the strings assigned to the act variable as a guide to what the code is doing (as opposed to comments in the code). If you change the rollback() to a commit() you will get ten extra records in the specified table.