CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    May 1999
    Location
    India
    Posts
    4

    Error while retrieving data with CRecordSet

    Dear all,

    I am creating a MFC dialog based application in VC++ 6.0.
    Database is MS-Access.
    Driver is ODBC.
    Platform: WIN NT.

    Description of my table is as follows.

    Table Name - Machine

    Machine ID (Primary key)- Number
    Machine Name - Text
    Machine Type - Text
    Clamping Tonnage - Number
    Injection Force - Number

    StdMachineSet is the object of class derived from CrecordSet.

    StdMachineSet.Open(CRecordset:ynaset,
    "SELECT DISTINCT [Machine Name] FROM Machine",
    CRecordset::readOnly);

    It gives me the error : Error retreiving record.

    When I changed the query to

    StdMachineSet.Open(CRecordset:ynaset,
    "SELECT * FROM Machine",
    CRecordset::readOnly);

    It works fine.

    What might be the problem?

    Regards,

    Anand.




  2. #2
    Join Date
    May 1999
    Posts
    17

    Re: Error while retrieving data with CRecordSet

    Just off the top of my head:

    SELECT DISTINCT returns a static recordset. If you try

    CRecordset::snapshot instead of CRecordset:ynaset

    your query might succeed.

    HTH,
    Peter



  3. #3
    Join Date
    May 1999
    Location
    India
    Posts
    4

    Re: Error while retrieving data with CRecordSet

    Hi Peter,
    It didn't work with CRecordset::snapshot also.
    Anand.


  4. #4
    Join Date
    May 1999
    Posts
    17

    Re: Error while retrieving data with CRecordSet

    OK,

    How does your DoFieldExchange function look?

    Regards,
    Peter


  5. #5
    Join Date
    May 1999
    Location
    India
    Posts
    4

    Re: Error while retrieving data with CRecordSet


    void CMachineSet:oFieldExchange(CFieldExchange* pFX)
    {
    //{{AFX_FIELD_MAP(CMachineSet)
    pFX->SetFieldType(CFieldExchange:utputColumn);
    RFX_Int(pFX, _T("[MachineID]"), m_MachineID);
    RFX_Text(pFX, _T("[Machine Name]"), m_Machine_Name);
    RFX_Text(pFX, _T("[Machine Type]"), m_Machine_Type);
    RFX_Double(pFX, _T("[Clamping Tonnage]"), m_Clamping_Tonnage);
    RFX_Double(pFX, _T("[Injection Force]"), m_Injection_Force);
    //}}AFX_FIELD_MAP
    }

    Regards,
    Anand.


  6. #6
    Join Date
    May 1999
    Posts
    17

    Re: Error while retrieving data with CRecordSet

    There's the problem: You have only the [Machine Name] field in your recordset. The Field exchange function expects all the fields of your table.

    Regards,
    Peter



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