CeCreateDatabase (RAPI)

Send Feedback

This function creates a new database on a remote Microsoft® Windows® CE–based device.

CEOID CeCreateDatabase(
  LPWSTR lpszName,
  DWORD dwDbaseType,
  WORD wNumSortOrder,


  • lpszName
    [in] Long pointer to a null-terminated string that specifies the name for the new database. The name can have up to 32 characters, including the terminating null character. If the name is too long, it is truncated and the database is created. Do not use an empty string as the database name.

Note   Do not create a database name that end with a backslash character "\".

  • dwDbaseType
    [in] Specifies the type identifier for the database. This is an application-defined value that can be used for any application-defined purpose. For example, an application can use the type identifier to distinguish address book data from to-do list data or use the identifier during a database enumeration sequence. See CeFindFirstDatabase for details. The type identifier is not meant to be a unique identifier for the database. The system does not use this value.
  • wNumSortOrder
    [in] Number of sort orders active in the database, with four (CEDB_MAXSORTORDER = 4) being the maximum number. This parameter can be zero if no sort orders are active. If this value is zero then the database engine creates a default sort order where "rgSortSpecs[0].propid = 0", and "rgSortSpecs[0].dwFlags = CEDB_SORT_GENERICORDER". This is only a placeholder and does not influence the insertion order of the records.

Note   Sort orders larger then CEDB_MAXSORTORDER are invalid.

  • rgSortSpecs
    [in] Pointer to an array of SORTORDERSPEC structures containing sort order descriptions. The size of the array is specified by wNumSortOrder. This parameter can be NULL if wNumSortOrder is zero.

Return Values

The object identifier of the newly created database — not a handle to an open database — indicates success. NULL indicates failure. To get extended error information, call CeGetLastError and CeRapiGetError. Possible values for CeGetLastError include the following:

    The object store does not contain enough space to create the new database.
    A parameter was invalid.
    A database already exists with the specified name.


Because sort orders increase the system resources needed to perform each insert and delete operation, keep the number of sort orders to a minimum. You can use the CeSetDatabaseInfo (RAPI) function to change the sort order later.

Note   Earlier versions of Windows CE assigned object identifiers to objects in other file systems, such as the file allocation table (FAT) file system. These object identifiers were guaranteed to be unique within a volume, but not across multiple volumes. Effective with version 3.0, only objects in the object store have valid, unique object identifiers and the object store is the only volume that can return an object identifier.

RAPI method calls that access databases will fail on devices running in restricted mode unless the database permissions are explicitly set to allow RAPI access. For more information, see RAPI Restricted Mode Security.


Pocket PC: Pocket PC 2000 and later
Smartphone: Smartphone 2002 and later
OS Versions: Windows CE 3.0 and later
Header: Rapi.h
Library: Rapi.lib

See Also

Remote API Functions | CeDeleteDatabase | CeFindFirstDatabase | CeOidGetInfo | CeOpenDatabase | CeSetDatabaseInfo

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.