This example sets the ODBCTimeout property to 120 seconds and then creates a query and runs it on a database on an ODBC server.
Cstring strCriteria;
CdbBookmark varSaveHere;
CdbDBEngine DBEng;
CdbDatabase dbsNorthwind;
CdbRecordset rstCustomers;
CdbQueryDef qdfCustomers;
dbsNorthwind = DBEng.OpenDatabase(_T("Northwind.mdb"));
// Create query.
qdfCustomers = dbsNorthwind.CreateQueryDef(_T("All Cust"), _T("SELECT * FROM Customers;"));
qdfCustomers.SetConnect(_T("ODBC;DSN=Human Resources; SERVER=HRSRVR; UID=Smith; PWD=Sesame"));
// Log in to server and run query.
qdfCustomers.SetODBCTimeout(120);
rstCustomers = qdfCustomers.OpenRecordset();