Basic VBScript for Elipse E3: Lesson 7 - GetADORecordSet
Query's GetADORecordSet method returns an ADO (ActiveX Data Object) type Recordset, resulting from the execution of the configured query.
The ADO Recordset object is used to access a chart's record in the database. It has the following properties and methods:
Properties: BOF: Returns true if the position of the pointer is previous to the first record. EOF: Returns true if the position of the pointer is posterior to the last record. RecordCount: Returns the number of records in the chart.
Methods: MoveFirst: Moves the pointer to the first record. MoveLast: Moves the pointer to the last record. MoveNext: Moves the pointer to the next record. MovePrevious: Moves the pointer to the previous record.
To access the records individually, we use Fields ("FieldName") command.
Example:
set RS = Screen.Item("Query1").GetADORecordset() for i=1 to RS.RecordCount Field1 = RS.Fields("Field1").Value Field2 = RS.Fields("Field2").Value Field3 = RS.Fields("Field3").Value MsgBox Field1 &vbTab& Field2 &vbTab& Field3 next
Exercises:
1. Insert a Database object in the project and configure it. 2. Create 3 demonstration tags and record them in the Database using the Historic object. In the Historic, set recording time to 0 seconds. 3. Insert a button on screen that when clicking records a register in the Historic. (WriteRecord) 4. Insert a query object on screen that searches the data saved by the Historic. 5. Create a button on screen that when clicking, displays every row in the Historic. Use the While command to repeat the script until it has not reached the end of the chart.