Partager via


CeCreateSession (EDB) (Windows CE 5.0)

Send Feedback

This function is used to create a session. A session is used to begin, commit, or roll back transactions.

This function does not work with CEDB databases. For more information about CEDB, see CEDB Reference.

HANDLE CeCreateSession(CEGUID*pGuid);

Parameters

  • pGuid
    [in] The CEGUID of the mounted volume for which to create the session. You can mount a volume by using the CeMountDBVolEx (EDB) function.

Return Values

A return value of INVALID_HANDLE_VALUE indicates failure. To get extended error information, call GetLastError. The following table lists possible values returned by GetLastError:

Return Value Description
ERROR_INVALID_PARAMETER Indicates that pGuid is NULL.
ERROR_NOT_FOUND Indicates that the volume is not mounted or that pGuid is not a valid GUID.

Remarks

Transactions are used to group a set of changes into a single atomic commit operation so that either all changes occur, or none do. Transactions can be used to guard against partially modified databases in the event of a system crash or power failure.

If you pass NULL for the session handle when opening a database, then EDB internally creates a new session that is used for that opened database, and each of the operations performed on the database is atomic. You can obtain the session handle for an opened database by calling the CeGetDatabaseSession (EDB) function.

Even if you pass a session handle when you open a database, you haven't started a transaction. You must first call the CeBeginTransaction (EDB) function for a session; then all changes made to all databases opened with that session are logged until you call the CeEndTransaction (EDB) function. The CeEndTransaction function allows you to either commit or roll back all of the changes that were made within the session since the matching CeBeginTransaction call was made.

Once you have opened a database, you cannot change its session.

A single transaction cannot span multiple volumes. However, you can perform a transaction that spans multiple databases within the same volume. You can do this by passing the same session handle in the call to CeOpenDatabaseInSession (EDB).

The handle returned from this function must be closed by calling the CloseHandle function. If a session is closed, and it is still in a transaction, all of the pending (uncommitted) changes are rolled back.

Requirements

OS Versions: Windows CE 5.0 and later.
Header: Windbase.h.
Link Library: Coredll.lib.

See Also

CeMountDBVolEx (EDB) | CeGetDatabaseSession (EDB) | CeBeginTransaction (EDB) | CeEndTransaction (EDB) | CeOpenDatabase (EDB) | CloseHandle

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.