CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: CRecordset

  1. #1
    Join Date
    Jun 1999
    Posts
    5

    CRecordset

    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;
    }






  2. #2
    Join Date
    May 1999
    Location
    Geneva
    Posts
    32

    Re: CRecordset

    Are you sure that in your Store Procedure there are nos insert, update or delete.
    With the error message I will look in the store procedure and not in the C++ code

    Christian Niquille


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured