Redigeeri

Jagamisviis:


CSession Class

Represents a single database access session.

Syntax

class CSession

Requirements

Header: atldbcli.h

Members

Methods

Name Description
Abort Cancels (terminates) the transaction.
Close Closes the session.
Commit Commits the transaction.
GetTransactionInfo Returns information regarding a transaction.
Open Opens a new session for the data source object.
StartTransaction Begins a new transaction for this session.

Remarks

One or more sessions can be associated with each provider connection (data source), which is represented by a CDataSource object. To create a new CSession for a CDataSource, call CSession::Open. To begin a database transaction, CSession provides the StartTransaction method. Once a transaction is started, you can commit to it using the Commit method, or cancel it using the Abort method.

CSession::Abort

Terminates the transaction.

Syntax

HRESULT Abort(BOID* pboidReason = NULL,
   BOOL bRetaining = FALSE,
   BOOL bAsync = FALSE) const throw();

Parameters

See ITransaction::Abort in the OLE DB Programmer's Reference.

Return Value

A standard HRESULT.

CSession::Close

Closes the session, which was opened by CSession::Open.

Syntax

void Close() throw();

Remarks

Releases the m_spOpenRowset pointer.

CSession::Commit

Commits the transaction.

Syntax

HRESULT Commit(BOOL bRetaining = FALSE,
   DWORD grfTC = XACTTC_SYNC,
   DWORD grfRM = 0) const throw();

Parameters

See ITransaction::Commit in the OLE DB Programmer's Reference.

Return Value

A standard HRESULT.

Remarks

For more information, see ITransaction::Commit.

CSession::GetTransactionInfo

Returns information regarding a transaction.

Syntax

HRESULT GetTransactionInfo(XACTTRANSINFO* pInfo) const throw();

Parameters

See ITransaction::GetTransactionInfo in the OLE DB Programmer's Reference.

Return Value

A standard HRESULT.

Remarks

For more information, see ITransaction::GetTransactionInfo in the OLE DB Programmer's Reference.

CSession::Open

Opens a new session for the data source object.

Syntax

HRESULT Open(const CDataSource& ds,
   DBPROPSET *pPropSet = NULL,
   ULONG ulPropSets = 0) throw();

Parameters

ds
[in] The data source for which the session is to be opened.

pPropSet
[in] A pointer to an array of DBPROPSET structures containing properties and values to be set. See Property Sets and Property Groups in the OLE DB Programmer's Reference in the Windows SDK.

ulPropSets
[in] The number of DBPROPSET structures passed in the pPropSet argument.

Return Value

A standard HRESULT.

Remarks

You must open the data source object using CDataSource::Open before passing it to CSession::Open.

CSession::StartTransaction

Begins a new transaction for this session.

Syntax

HRESULT StartTransaction(ISOLEVEL isoLevel = ISOLATIONLEVEL_READCOMMITTED,
   ULONG isoFlags = 0,
   ITransactionOptions* pOtherOptions = NULL,
   ULONG* pulTransactionLevel = NULL) const throw();

Parameters

See ITransactionLocal::StartTransaction in the OLE DB Programmer's Reference.

Return Value

A standard HRESULT.

Remarks

For more information, see ITransactionLocal::StartTransaction in the OLE DB Programmer's Reference.

See also

CatDB
OLE DB Consumer Templates
OLE DB Consumer Templates Reference