Working with the Recordset Object

A recordset is a virtual database table whose fields and rows correspond to a subset of the fields and rows in an actual database table on the Windows CE–based device. When you change data in the recordset, the recordset stores the changes in memory, enabling you to cancel the changes before the underlying database is updated. Because ADOCE databases are intended for single user access, ADOCE does not support batch updates. Only one row at a time can have data that is changed but not committed to the underlying database.

While ADOCE databases are primarily single-user, other applications can open a recordset on the same database. For each recordset that it opens, ADOCE generates a keyset that holds pointers to all the database rows referred to by that recordset. In a multi-user scenario, the keyset may hold pointers to records that have been deleted by other applications after the recordset was initially opened; this is because the keyset is not dynamically updated with changes to the underlying database. Attempting to access the deleted records generates an error. When rows are added to the database by means of the current open recordset, the keyset for that recordset is also updated.

Additionally, in a multi-user scenario, when rows are added to the database by other applications, the keysets for other recordsets referring to that database are not dynamically updated, and the rows added by other applications are not visible. To generate a new keyset and view additions and deletions by other applications, close the recordset and reopen it. Recordsets that are duplicated using the Clone method share a common keyset.

When you change the structure of the recordset table, the changes to the underlying database table are immediate.

Creating a Recordset Object

To create a Recordset object, use the CreateObject function to assign a Recordset object reference to a variable. The following code example shows how to do this.

Dim rs   'Create a variable for the Recordset object reference
Set rs = CreateObject("adoce.recordset")

Once you have created a Recordset object, you can use the properties and methods of the Recordset object to read and manipulate data.