The following example creates an SQL pass-through query that returns records from an external database.
CdbDBEngine dbeng;
CdbDatabase dbsNorthwind;
CdbQueryDef qdfPassThrough;
dbsNorthwind = dbeng.OpenDatabase(_T("Northwind.mdb"));
qdfPassThrough = dbsNorthwind.CreateQueryDef(_T("October Orders"),
_T("SELECT * From Orders WHERE ShipCity = 'London'"));
qdfPassThrough.SetConnect(_T("ODBC;
DSN=MySQLDBDSN;UID=Chrissy;PWD=FourOh;"));
qdfPassThrough.SetReturnsRecords(TRUE);
dbsNorthwind.Close();