Compartilhar via


CDatabase::OnSetOptions

The framework calls this member function when directly executing a SQL statement with the ExecuteSQL member function.

virtual void OnSetOptions(
   HSTMT hstmt 
);

Parameters

  • hstmt
    The ODBC statement handle for which options are being set.

Remarks

CRecordset::OnSetOptions also calls this member function.

OnSetOptions sets the login timeout value. If there have been previous calls to the SetQueryTimeout and member function, OnSetOptions reflects the current values; otherwise, it sets default values.

Observação

Prior to MFC 4.2, OnSetOptions also set the processing mode to either snychronous or asynchronous. Beginning with MFC 4.2, all operations are synchronous. To perform an asynchronous operation, you must make a direct call to the ODBC API function SQLSetPos.

You do not need to override OnSetOptions to change the timeout value. Instead, to customize the query timeout value, call SetQueryTimeout before creating a recordset; OnSetOptions will use the new value. The values set apply to subsequent operations on all recordsets or direct SQL calls.

Override OnSetOptions if you want to set additional options. Your override should call the base class OnSetOptions either before or after you call the ODBC API function SQLSetStmtOption. Follow the method illustrated in the framework's default implementation of OnSetOptions.

Requirements

Header: afxdb.h

See Also

Reference

CDatabase Class

Hierarchy Chart

CDatabase::ExecuteSQL

CDatabase::SetQueryTimeout

CRecordset::OnSetOptions

Other Resources

CDatabase Members