The Query’s GetADORecordSet method returns a Recordset object of type ADO (ActiveX Data Object), the result of executing the configured query.
The ADO RecordSet object is used to access records from a database table. It has the following properties and methods:
Properties
Properties are important to check the existence of values in a table. They can be used as security scripts. As an example, we will use the following table:
Figure 1: Table used
-
BOF: Returns true if the pointer position is before the first record. In the following example, the script checks if the pointer is before the first record. If this condition is true, returns a message informing that there is no records before.
Figure 2: Protection script using the BOF method
-
EOF: Returns true if the pointer position is after the last record. In the following example, the script checks if the pointer is after the last record. If this condition is true, returns a message informing that there is no records after.
Figure 3: Protection script using the EOF method
-
RecordCount: Returns the number of records in the table. Example:
Figure 4: Script using the RecordCount method
Methods
Methods are used to perform samplings on records, thus getting values from all records precisely.
- MoveFirst: Moves the pointer to the first record. Example:
Figure 5: Script showing how to use the MoveFirst method
-
MoveLast: Moves the pointer to the last record. Example:
Figure 6: Script showing how to use the MoveLast method
-
MoveNext: Moves the pointer to the next record. Example:
Figure 7: Script showing how to use the MoveNext method
-
MovePrevious: Moves the pointer to the previous record. Example:
Figure 8: Script showing how to use the MovePrevious method
Exercise
-
Create a button which counts the number of existing records in the Historic and returns a message with this value.
-
Create a button which informs the value of the first record.
-
Create a button which informs the value of the last record.