Raju Nalawade
August 17th, 1999, 08:46 AM
I am getting the following error message when trying to call the stored procedure. This stored procedure returns me the record. Is there any syntax error in calling the sp. Please suggest solution at earliest.
0042113C : Cannot open a cursor on a stored procedure that has anything other than a single select statement in it.
BOOL GetParticipantList(void)
{
CString sqlString;
char scheduleKey[10];
CRecordset participantList(&dbEasyDiary);
itoa(5748, scheduleKey, 10);
sqlString.Format("{CALL sp_getUsersInAppointment(5748, 0)}");
// sqlString = "{CALL sp_getUsersInAppointment('" + scheduleKey + "')}";
try
{
participantList.Open(CRecordset::snapshot, (LPCTSTR)sqlString, CRecordset::readOnly );
}
catch(CDBException *e)
{
char str[1024];
e->GetErrorMessage(str, 1024);
cout << "Error: " << e->m_strError << " : " << str << endl;
cout << "Failed Open() : GetParticipantList" << endl;
return FALSE;
}
long numberOfParticipants = participantList.GetRecordCount();
if (numberOfParticipants == -1)
{
cout << "GetParticipantList Failed 2 !!!" << endl;
return FALSE;
}
CDBVariant userKey, isInitiator, firstName, lastName, eMail;
participantList.MoveFirst();
while (!participantList.IsEOF())
{
participantList.GetFieldValue("UserKey", userKey);
participantList.GetFieldValue("IsInitiator", isInitiator);
participantList.GetFieldValue("FirstName", firstName);
participantList.GetFieldValue("lastName", lastName);
participantList.GetFieldValue("eMail", eMail);
cout << userKey.m_pstring << " ";
cout << isInitiator.m_iVal << " ";
cout << firstName.m_pstring << " ";
cout << lastName.m_pstring << " ";
cout << eMail.m_pstring << endl;
}
return TRUE;
}
0042113C : Cannot open a cursor on a stored procedure that has anything other than a single select statement in it.
BOOL GetParticipantList(void)
{
CString sqlString;
char scheduleKey[10];
CRecordset participantList(&dbEasyDiary);
itoa(5748, scheduleKey, 10);
sqlString.Format("{CALL sp_getUsersInAppointment(5748, 0)}");
// sqlString = "{CALL sp_getUsersInAppointment('" + scheduleKey + "')}";
try
{
participantList.Open(CRecordset::snapshot, (LPCTSTR)sqlString, CRecordset::readOnly );
}
catch(CDBException *e)
{
char str[1024];
e->GetErrorMessage(str, 1024);
cout << "Error: " << e->m_strError << " : " << str << endl;
cout << "Failed Open() : GetParticipantList" << endl;
return FALSE;
}
long numberOfParticipants = participantList.GetRecordCount();
if (numberOfParticipants == -1)
{
cout << "GetParticipantList Failed 2 !!!" << endl;
return FALSE;
}
CDBVariant userKey, isInitiator, firstName, lastName, eMail;
participantList.MoveFirst();
while (!participantList.IsEOF())
{
participantList.GetFieldValue("UserKey", userKey);
participantList.GetFieldValue("IsInitiator", isInitiator);
participantList.GetFieldValue("FirstName", firstName);
participantList.GetFieldValue("lastName", lastName);
participantList.GetFieldValue("eMail", eMail);
cout << userKey.m_pstring << " ";
cout << isInitiator.m_iVal << " ";
cout << firstName.m_pstring << " ";
cout << lastName.m_pstring << " ";
cout << eMail.m_pstring << endl;
}
return TRUE;
}