Modifying the Sort Order
When you are creating a database, you can define up to four different sort orders. Typically, each record in a database contains a similar set of properties, and each type of property shares the same property identifier. For example, each record in a Contacts database might contain a name, street address, city, state or province, postal code, and telephone number. All name properties would have the same property identifier, all street addresses would have the same property identifier, and so on. You can select one of these properties and direct the system to sort the records, based on that property. However, you cannot perform a sort on a binary property. The order in which the records are sorted affects the order in which the CeSeekDatabase database-seeking function finds records in the database.
You specify the four sort orders that you want to use on a database when you call the CeOpenDatabase or CeOpenDatabaseEx function by using the SORTORDERSPEC structure. SORTORDERSPEC contains the identifier of a single property on which the database properties are to be sorted. SORTORDERSPEC also includes a combination of flags that indicate whether to sort the records in ascending or descending order, whether the sort is case-sensitive, and whether to place records that do not contain the specified property before or after all of the other records. By default, sorting is done in ascending order and is case-sensitive. Windows CE places all of the records that do not contain the specified property at the end of all of the other records. Although you can have only one sort order active for each handle, you can open multiple handles to a given database. By using multiple handles, you can use more than one sort order.
You can change these four sort orders or other database properties by calling the CeSetDatabaseInfoEx function. CeSetDatabaseInfoEx lets you change the database name, type, or any of the four sort orders. However, it is more efficient to include any necessary sort orders when you create the database. When you change a sort order, Windows CE parses the database and changes each record. This process might take several minutes on a large database. If you must change the sort order, you should inform the user of the projected time delay.