Chained CRUD - Terminal Methods
Terminal methods execute the actual database operations. After execution, the builder state is automatically reset (ResetBuilder). For architecture details, see Chained CRUD Overview.
Field - Set Field Value
Used with RowCreate and RowUpdate to set insert/update field values.
Syntax
vb
Function Field(ByVal FieldName As String, ByVal Value As Variant) As cDataBaseExample
vb
' Set field values for insert
db.Table("users").Field("name", "Zhang San").Field("age", 25).RowCreate
' Set field values for update
db.Table("users").Where("id=?", 1).Field("name", "Zhang San Updated").Field("age", 26).RowUpdateRowCreate - Create Row
Syntax
vb
Function RowCreate() As cDataBaseUsage Patterns
vb
' Pattern 1: Chained Field (recommended, one-line insert)
With db.Table("users")
.Field "name", "Zhang San"
.Field "age", 25
.Field "email", "zhang@example.com"
.RowCreate
End With
' Pattern 2: Traditional Rs editing (suitable for per-field judgment scenarios)
With db.Table("users").RowCreate
.Rs!name = "Zhang San"
.Rs!age = 25
.Rs.Update
End With
' Get auto-increment ID after insert
With db.Table("users")
.Field "name", "Li Si"
.RowCreate
Debug.Print "New ID: " & db.LastInsertId
End WithRowRead - Query Rows
Syntax
vb
Function RowRead() As cDataBaseQuery results are stored in db.Rs (Recordset), accessible via db.Rs!FieldName.
Example
vb
' Simple query
If db.Table("users").Where("id=?", 1).RowRead Then
Debug.Print db.Rs!name
End If
' Complex chained query
db.Table("users") _
.Columns("id,name,age") _
.Where("age>?", 18) _
.WhereIn("dept", "IT,HR") _
.OrderByDesc("age") _
.Limit(10) _
.RowRead
' Iterate results
If db.Table("users").Where("status=?", "active").RowRead Then
Do Until db.Rs.EOF
Debug.Print db.Rs!name & " - " & db.Rs!age
db.Rs.MoveNext
Loop
End IfRowUpdate - Update Row
Syntax
vb
Function RowUpdate() As cDataBaseUsage Patterns
vb
' Pattern 1: Chained Field (recommended, one-line update)
With db.Table("users").Where("id=?", 1)
.Field "name", "Zhang San Updated"
.Field "age", 26
.RowUpdate
End With
' Pattern 2: Traditional Rs editing
With db.Table("users").Where("id=?", 1).RowUpdate
.Rs!name = "Zhang San Updated"
.Rs.Update
End With
' Batch update (with WhereIn)
With db.Table("users").WhereIn("id", 1, 2, 3)
.Field "status", "archived"
.RowUpdate
End WithNote: RowUpdate requires a Where condition to prevent accidental full-table updates.
RowDelete - Delete Row
Syntax
vb
Function RowDelete() As cDataBaseExample
vb
' Delete by ID
db.Table("users").Where("id=?", 1).RowDelete
' Batch delete
db.Table("users").WhereIn("id", 5, 8, 13).RowDelete
' Conditional delete
db.Table("logs").Where("created_at<'2025-01-01'").RowDelete
' Combined condition delete
db.Table("users") _
.Where("status=?", "expired") _
.WhereNull("email") _
.RowDeleteNote: RowDelete requires a Where condition to prevent accidental full-table deletion.
Last Updated: 2026-06-26