Access Windows CE Databases from .NET CF
João Paulo Figueira shows how to access Windows CE Databases from .NET Compact Framework. It explains the concepts behind the CE property databases and the APIs involved to use them:
- CeDbApi - Contains all the imported API functions used by the other classes.
- CeDbException - Type of exceptions thrown by the wrapper.
- CeDbInfo - Wraps a CEDBASEINFO structure, needed to create new databases and to query existing ones.
- CeDbProperty - Models a property value.
- CeDbPropertyCollection - A collection of properties, searchable by property id.
- CeDbPropertyID - Static class to manage property ids.
- CeDbRecord - Models a database record.
- CeDbRecordSet - Implements data access and navigation in the database.
- CeDbTable - Identifies a database in a volume.
- CeDbVolume - Models a database volume.
- CeOidInfo - Retrieves information about an existing database (may be generalized to other object store items).
The example code in the article shows how to use the Windows CE property databases CEDB to access the contacts on the Pocket PC.
Each database comprises only a single table that has no preset structure. Records may have a variable number of fields and only four sort orders are allowed per database. These databases may be created directly on the object store, or mounted on a file.
Although they seem to be quite limited in their definition as well as in their use (one may experience problems on tables with over 1000 records), these databases are quite ubiquitous on the Pocket PC: they support all the PIM applications, support the popular “Pocket Access” format and are directly accessible from the desktop via RAPI.
The Pocket Outlook Object Model makes life easier though if you are interested in Outlook items like Contacts, Tasks and Calendar.