Navigating Through and Manipulating Data
Once a recordset has been opened, you can navigate through it using Move x, MoveFirst, MoveNext, MovePrevious, and MoveLast. The Move method takes a single parameter, and that is the number of records to navigate. A negative number will cause the cursor to move backward (toward the first record) in the recordset.
Adding Records
To add a new record, use the AddNew method. No parameters are required, although you can specify the fields and values in the call. The cursor points to the newly added record, so updates can be made immediately to the fields without having to navigate to it.
*Note: Before calling Update or UpdateBatch, you must provide a value for any fields that are not nullable.
In immediate-update mode, an empty record is written to the data store, then updates to the field are stored as they are made. In deferred-update mode, an empty record is created, but that record is not written until Update or UpdateBatch is called.
rs.Open "Course", "Provider=PervasiveOLEDB;Data Source=Demodata", adOpenDynamic, adLockBatchOptimistic, adCmdTableDirect
rs.AddNew
rs!Field1 = 0
rs!Field2 = "TextValue"
rs.UpdateBatch
rs.Close
or
rs.Open "Course", "Provider=PervasiveOLEDB;Data Source=Demodata", adOpenDynamic, adLockBatchOptimistic, adCmdTableDirect
rs.AddNew Array("Field1", "Field2"), Array(0, "TextValue")
rs.UpdateBatch
rs.Close
Deleting Records
To delete a record, use the Delete method. There is one optional parameter, and that specifies which record(s) to delete. Currently, the PSQL provider only supports the default, adAffectCurrent.
rs.Open "Course", "Provider=PervasiveOLEDB;Data Source=Demodata", adOpenDynamic, adLockOptimistic, adCmdTableDirect
' navigate to the record to be deleted
rs.Delete adAffectCurrent
rs.Close
Updating Records
To update a record, assign the desired values to the appropriate fields, then call Update or UpdateBatch.
rs.Open "Course", "Provider=PervasiveOLEDB;Data Source=Demodata", adOpenDynamic, adLockBatchOptimistic, adCmdTableDirect
' navigate to the record to be updated
rs!Field4 = "Changed text"
rs.UpdateBatch
rs.Close