Creating a Database

Use the CeCreateDatabaseEx function to create a database in any volume. CeCreateDatabaseEx identifies the volume, names the database, identifies the sort order, and lets you pass in a user-defined type identifier. The sort order is an index that is applied to a database to manipulate the record ordering. Although you define the sort order when the database is created, you can alter the sort order later. The type identifier, while user-defined, is commonly used to identify similar types of databases.

    To create a database within the object store with Windows CE 2.10 and later

  1. Call the CREATE_SYSTEMGUID macro to create an object identifier for the object store.

    The returned GUID can act as a standard identifier for a handle.

  2. Call CeCreateDatabaseEx, using the CEGUID created in the previous call to CREATE_SYSTEMGUID.

When you create a database on a mounted volume, it is usually a good idea to make the database uncompressed. Accessing a mounted volume is usually slower than accessing the object store: compressing and decompressing slows the process even further. Therefore, create your database as an uncompressed database, unless you expect the database to be larger than the storage card can contain.

    To set compression on a database after the database is created

  1. Create a CEDBASEINFO structure with the CEDB_VALIDBFLAGS value set in the dwFlags value.
  2. Toggle off the CEDB_NOCOMPRESS bit in the dwFlags value by using the following code fragment.
    dwFlags &= ~(CEDB_NOCOMPRESS);
    
  3. Call the CeSetDatabaseInfoEx function with the previous CEDBASEINFO structure.