CeOpenDatabase

The CeOpenDatabase function opens an existing database. A RAPI version of this function exists and is also called CeOpenDatabase.

Syntax

HANDLE CeOpenDatabase(PCEOID poid, LPWSTR lpszName, CEPROPID propid, DWORD dwFlags, HWND hwndNotify);

At a Glance

Header file: Winbase.h
Component: fsdbase
Platforms: H/PC
Windows CE versions: 1.01 and later

Parameters

poid
Pointer to the object identifier of the database to be opened. To open a database by name, set the value pointed to by poid to zero to receive the object identifer of the newly opened database when a database name is specified for lpszName.
lpszName
Pointer to the name of the database to be opened. This parameter is ignored if the value pointed to by poid is non-zero.
propid
Property identifier of the primary key for the sort order in which the database is to be traversed. All subsequent calls to CeSeekDatabase assume this sort order. This parameter can be zero if the sort order is not important.
dwFlags
Action flag. The following values are supported:
CEDB_AUTOINCREMENT
Causes the current seek position to be automatically incremented with each call to the CeReadRecordProps function.
0 (ZERO)
Current seek position is not incremented with each call to CeReadRecordProps.
hwndNotify
Handle to the window to which notification messages (DB_CEOID_*) will be posted if another thread modifies the given database while you have it open. This parameter can be NULL if you do not need to receive notifications.

Return Values

If the function succeeds, the return value is a handle to the open database. If the function fails, the return value is INVALID_HANDLE_VALUE. To get extended error information when within a CE program call GetLastError. If within a RAPI program, call CeGetLastError. GetLastError and CeGetLastError may return one of the following values:

ERROR_INVALID_PARAMETER
A parameter was invalid.
ERROR_FILE_NOT_FOUND
No database exists with the specified name. This value applies only if the value pointed to by poid was set to NULLwhen the function was called.
ERROR_NOT_ENOUGH_MEMORY
No memory was available to allocate a database handle.

Remarks

Use the CeCloseHandle function to close the handle returned by the CeOpenDatabase function.

Unlike many other traditional databases, opening and closing a database does not imply any transactioning. In other words, the database is not committed at the closing—it is committed after each individual call.

For more information, see Accessing Persistent Storage.

When writing applications for Windows CE version 1.0, use the PegOpenDatabase function.

See Also

CeCloseHandle, CeCreateDatabase, CeSeekDatabase