Writing a database application for PDAs
Published: 30 Aug 2002 15:47 BST
The CeWriteRecordProps function adds a record to the database, as shown in the following code snippet:
CEOID CeWriteRecordProps(
HANDLE hDbase,
CEOID oidRecord,
WORD cPropID,
CEPROPVAL * rgPropVal );
You need to fill the CEPROPVAL structure with the properties that its table is going to contain. This is akin to assigning data types to columns in a standard Access or SQL database. Table A outlines the legal data types.
|
Our application stores the following properties in the CEDB database as shown in the following list:
- strTitle--256-character Unicode string
- nHour--short int
- nMinute--short int
- nRating--float
- strDescription--1,024-character Unicode string
Reading from the database
You must take care to set the "Seek" of the database to the right position before reading. The Overview tab enumerates all the records in the database from start to finish whenever that Overview property page receives focus.
The CeReadRecordPropsEx requires a handle to the database and a buffer to dump all the contents of the record into. CeReadRecordPropsEx can even allocate an appropriate amount of RAM on the heap, which you have to free after the function call. There is no need to respecify the CEPROPVAL.
CEOID CeReadRecordPropsEx (
HANDLE hDbase,
DWORD dwFlags,
LPWORD lpcPropID,
CEPROPID * rgPropID,
LPBYTE * lplpBuffer,
LPDWORD lpcbBuffer,
HANDLE hHeap );
Closing the database
You close the database by unmounting the volume that the database is located on. The function CeUnmountDBVol helps accomplish that, as shown in the following code:
BOOL CeUnmountDBVol (
PCEGUID pceguid );
Conclusion
You now have the foundation and code to write a simple, quick database application using Windows CE. In the next installment, I will cover an ADOCE client application that hits SQL Server via a wireless connection located on a corporate backbone.
Have your say instantly, in the Tech Update forum.
For a weekly round-up of the enterprise IT news, sign up for the Tech Update newsletter.
Find out what's where in the new Tech Update with our Guided Tour.
Tell us what you think in the Mailroom.









