CDatabase::SetQueryTimeout

Call this member function to override the default number of seconds to allow before subsequent operations on the connected data source time out.

void SetQueryTimeout( 
   DWORD dwSeconds  
);

Parameters

  • dwSeconds
    The number of seconds to allow before a query attempt times out.

Remarks

An operation might time out due to network access problems, excessive query processing time, and so on. Call SetQueryTimeout prior to opening your recordset or prior to calling the recordset's AddNew, Update or Delete member functions if you want to change the query timeout value. The setting affects all subsequent Open, AddNew, Update, and Delete calls to any recordsets associated with this CDatabase object. Changing the query timeout value for a recordset after opening does not change the value for the recordset. For example, subsequent Move operations do not use the new value.

The default value for query timeouts is 15 seconds. Not all data sources support the ability to set a query timeout value. If you set a query timeout value of 0, no timeout occurs; the communication with the data source may stop responding. This behavior may be useful during development. If the data source does not support timeout, you get trace output but not an exception.

Requirements

Header: afxdb.h

See Also

Reference

CDatabase Class

Hierarchy Chart

CDatabase::SetLoginTimeout