more...
http://www.vb-world.com/databases/sqltutorial4/index2.html
Visual Basic Code
Private Sub Command1_Click()
Dim objConn As New ADODB.Connection
Dim objRS As New ADODB.Recordset
'Objects to be used in this operation -'objConn, the basic connection
'objRS, to hold our recordset
With objConn
.ConnectionString = "Driver=SQL Server;Server=COLOSSI;" & _
"Database=PUBS;User ID=KarlMoore;Password=TEST"
.Open
End With
'Get a connection to the database
objConn.BeginTrans
'Begin Transactions here!
objRS.Open "Select * from Jobs", objConn
'Open the recordset, selecting all from the Jobs table
objRS.AddNew
objRS.Fields("job_desc") = "My New Test Job"
objRS.Fields("min_lvl") = 10
objRS.Fields("max_lvl") = 20
objRS.Update
'Add a new record... and then...
objRS.AddNew
objRS.Fields("job_desc") = "My Second New Test Job"
objRS.Fields("min_lvl") = 20
objRS.Fields("max_lvl") = 30
objRS.Update
'... another!
If MsgBox("Do you want to commit?", vbYesNo + vbQuestion) = vbYes Then
objConn.CommitTrans
Else
objConn.RollbackTrans
End If
'Run the CommitTrans or RollbackTrans methods,
'depending on user response
objRS.Close
Set objRS = Nothing
objConn.Close
SetobjConn = Nothing
'Close all references
End Sub