60 likes | 194 Vues
This article explores ADO Recordset objects, which are essential for data manipulation in databases. A Recordset represents a set of records from a database table or the results of an executed command, constructed from rows and columns. Key navigation methods include MoveFirst, MoveLast, MoveNext, and MovePrevious. We also cover properties like BOF and EOF to indicate record boundaries, the RecordCount property for counting records, and the AbsolutePosition property to track the current record. Learn how to effectively manage and navigate data using ADO.
E N D
Recordset Object (ADO) • When you use ADO, you manipulate data almost entirely using Recordset objects. • A Recordset object represents the entire set of records from a database table or the results of an executed command. • All Recordset objects are constructed using records (rows) and fields (columns).
Recordset Navigation Methods • Navigate through the records in a Recordset with the following Recordset methods • MoveFirst • MoveLast • MoveNext • MovePrevious • Move • Examples: Adodc1.Recordset.Move +5 Adodc1.Recordset.MoveFirst Adodc1.Recordset.MoveLast
RecordsetBOF and EOF Properties • The BOF and EOF properties indicate the beginning or end of the Recordset. • The BOF or EOF property is True when you move one record past the first or last record. • If both BOF and EOF are True, there are no records in the Recordset. • Example: If Adodc1.Recordset.BOF = True Then Adodc1.Recordset.MoveFirst
RecordsetRecordCount Property • Use the RecordCount property to return the number of records in a Recordset object. • The property returns -1 when ADO cannot determine the number of records. • Reading the RecordCount property on a closed Recordset causes an error. • Example: txtRecordCount.Text = Adodc1.Recordset.RecordCount
RecordsetAbsolutePosition Property • Use the AbsolutePosition property to determine the current record number • The AbsolutePosition property is a Long Integer between 1 and the number of records in the Recordset. • Example: txtCurrentRecord.Text = Adodc1.Recordset.AbsolutePosition