共用方式為


CDatabase Members

Base Class Members

CObject Members

Data Members

m_hdbc

Open Database Connectivity (ODBC) connection handle to a data source. Type HDBC.

Construction

CDatabase

Constructs a CDatabase object. You must initialize the object by calling OpenEx or Open.

Close

Closes the data source connection.

Open

Establishes a connection to a data source (through an ODBC driver).

OpenEx

Establishes a connection to a data source (through an ODBC driver).

Database Attributes

CanTransact

Returns nonzero if the data source supports transactions.

CanUpdate

Returns nonzero if the CDatabase object is updatable (not read-only).

GetBookmarkPersistence

Identifies the operations through which bookmarks persist on recordset objects.

GetConnect

Returns the ODBC connection string used to connect the CDatabase object to a data source.

GetCursorCommitBehavior

Identifies the effect of committing a transaction on an open recordset object.

GetCursorRollbackBehavior

Identifies the effect of rolling back a transaction on an open recordset object.

GetDatabaseName

Returns the name of the database currently in use.

IsOpen

Returns nonzero if the CDatabase object is currently connected to a data source.

SetLoginTimeout

Sets the number of seconds after which a data source connection attempt will time out.

SetQueryTimeout

Sets the number of seconds after which database query operations will time out. Affects all subsequent recordset Open, AddNew, Edit, and Delete calls.

Database Operations

BeginTrans

Starts a "transaction" — a series of reversible calls to the AddNew, Edit, Delete, and Update member functions of class CRecordset — on the connected data source. The data source must support transactions for BeginTrans to have any effect.

BindParameters

Allows you to bind parameters before calling CDatabase::ExecuteSQL.

Cancel

Cancels an asynchronous operation or a process from a second thread.

CommitTrans

Completes a transaction begun by BeginTrans. Commands in the transaction that alter the data source are carried out.

ExecuteSQL

Executes a SQL statement. No data records are returned.

Rollback

Reverses changes made during the current transaction. The data source returns to its previous state, as defined at the BeginTrans call, unaltered.

Database Overridables

OnSetOptions

Called by the framework to set standard connection options. The default implementation sets the query timeout value. You can establish these options ahead of time by calling SetQueryTimeout.

See Also

Reference

CDatabase Class

Hierarchy Chart