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

    Mu;tiple Recordset/ODBC/Access question

    I have a basic "add-change-delete" CRecordView based application which uses ODBC and Access.
    Everything works great, and I am using a single CRecordSet. I would like to have simultaneous access to another CRecordset.
    For simplicity (my actual case is more complicated), lets say my record view has 6 fields: Name, Address, City, State, Zip and Age. The Age is in its own recordset. For every name/address that I scroll through in the database, I would like the age of the person also displayed for each record.
    I created a CDatabase object.
    I then constructed a recordset, passing a CDatabase pointer to the CRecordset constructor.


    // MyDoc.h
    CMyPrimarySet* m_pSet;
    CDatabase m_database;
    //...




    CMyDocument::OnNewDocument
    {
    if (!CDocument::OnNewDocument())
    return FALSE;
    if(m_pSet == NULL) {
    m_pSet = new CMyPrimarySet(&m_database);
    CString strConnect = m_pSet->GetDefaultConnect();
    m_database.Open(NULL, FALSE, FALSE, strConnect, FALSE);
    }
    return TRUE;
    }




    I have this in my view's OnInitialUpdate:


    CMyView::OnInitialUpdate()
    {
    //...
    m_pSet = GetDocument()->m_editClearingLabelsSet;
    //...
    AgeRecordSet m_pAgeset(&pDoc->m_database);

    }




    Ok, I think I have the multiple recordsets set up correctly. Now, I am totally confused about the proper way to sequence through my records and have the age displayed along with each record.
    I have tried several different ways, all to no avail.

    Any clues?
    Thanks in advance.



  2. #2
    Join Date
    May 1999
    Location
    Wisconsin, USA
    Posts
    953

    Re: Mu;tiple Recordset/ODBC/Access question

    Do you have a field in one table that is the same in the other?

    For example, you could store a customer ID in each table, or some type of AgeID in the customer table. You could use the ID we locate the proper record.



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