Gets the next set of records, if any, returned by a multi-part select query in an OpenRecordset call, and returns a value indicating whether one or more additional records are pending (ODBCDirect workspaces only).
Syntax
BOOLNextRecordset(VOID);
Returns
TRUE indicates the next set of records is available; FALSE indicates that no more records are pending and CdbRecordset is now empty.
Remarks
In an ODBCDirect workspace, you can open a CdbRecordset containing more than one select query in the source argument of OpenRecordset, or the SQL property of a select query CdbQueryDef object, as in the following example.
SELECT LastName, FirstName FROM Authors
WHERE LastName = 'Smith';
SELECT Title, ISBN FROM Titles
WHERE Pub_ID = 9999
The returned CdbRecordset will open with the results of the first query. To obtain the result sets of records from subsequent queries, use the NextRecordset method.
If more records are available (that is, there was another select query in the OpenRecordset call or in the SQL property), the records returned from the next query will be loaded into the CdbRecordset, and NextRecordset will return True, indicating that the records are available. When no more records are available (that is, results of the last select query have been loaded into the CdbRecordset), then NextRecordset will return False, and the CdbRecordset will be empty.
You can also use the Cancel method to flush the contents of a CdbRecordset. However, Cancel also flushes any additional records not yet loaded.
Usage
#include <afxole.h>
#include <dbdao.h>
CdbDBEngine dben;
CdbWorkspace ws;
CdbDatabase dbs;
CdbRecordset rst;
LPTSTR szSelect = // Two queries...
"SELECT LastName, FirstName "
"FROM Authors WHERE LastName = 'Smith';"
"SELECT Title, ISBN FROM Titles WHERE "
"Pub_ID = 9999";
...
ws = dben.CreateWorkspace(...,dbUseODBC);
dbs = ws.OpenDatabase(...);
rst = dbs.OpenRecordset(szSelect);
while( rst.NextRecordset())
{ ... // Process each query...
if (Error)
rst.Cancel();
else
rst.Update();
...
}
rst.Close();