CRecordset::Open() - Invalid cursor state
When you call a stored procedure in C++ (MFC) through CRecordset
and the stored procedure does NOT return any result set,you
will get the following DBException :
"Invalid cursor state"
This happens because CRecordset expects a result set
and the stored procedure does NOT return any result set,you
will get the following DBException :
"Invalid cursor state"
This happens because CRecordset expects a result set
style="font-family:arial;">and the Open() method automatically calls MoveFirst() method
that moves to the first record once the recordset is opened.
To workaround this issue you can do one of the following:
that moves to the first record once the recordset is opened.
To workaround this issue you can do one of the following:
- Override CRecordset::Open() to prevent calling the code that moves to the first record once the recordset is opened.
- Change the SP so it will return empty record set.
- Use CDatabase::m_hdbc and do your own binding of input parameters.
- Use CDatabase::ExecuteSQL() instead of CRecordset class.
More information: http://support.microsoft.com/kb/137814