How to get result sets from a batch? -
11-18-2009
, 05:22 AM
Using Microsoft C++ we can query multiple result sets from a single stored
procedure call with code similar to this one:
CRecordset rs(&db);
rs.Open(CRecordset::forwardOnly, "{call PerformanceTest}",
CRecordset::readOnly);
for (int i = 0; i < j; i++) {
rs.FlushResultSet();
this->m_bar.SetPos(i);
}
rs.Close();
Now we lilke to query multiple result sets from a SQL batch, so we tried
doing this one:
CRecordset rs(&db);
rs.Open(CRecordset::forwardOnly, "BEGIN DECLARE ... SELECT ... END;",
CRecordset::readOnly);
for (int i = 0; i < j; i++) {
rs.FlushResultSet();
this->m_bar.SetPos(i);
}
rs.Close();
At runtime this results in an exception as the MFC class does not find the
list of columns (even if we provide rs.m_nFields = 2 before Opening).
What is the correct way to do this?
Thanks
Markus |