troubleshooting Question

DAORecordSet question

Avatar of AveryH
AveryH asked on
System Programming
1 Comment1 Solution162 ViewsLast Modified:
I am working on a database using DAORecordsets. Part of the requirement is to add information to a record about a parameter that may be passed when the program is executed. (If no parameter is passed, then a blank record is appended and the program behaves as it ought).

I create the recordset, check that I can update, call addnew, enter the data on the form and then call update. Everything appears to do what it should do except that the new record is not added to the database.

When I step through the code, I can see all the values that have been added by the use on the data capture form; I can see those values being copied to the recordset. However, as soon as I call the Update finction, the recordset displays the value for the first record in the database.

The code fragment below demonstrates is cut staright from my app. First the OnInitialUpdate method

void CSACView::OnInitialUpdate()
{
     okToQuit = TRUE;
     newRec = FALSE;
     m_pSet = &GetDocument()->m_sACSet;

     CDaoRecordView::OnInitialUpdate();
     GetParentFrame()->RecalcLayout();
     ResizeParentToFit();

     if (m_pSet->CanUpdate() && newRec)
          OnGetRecordset()->AddNew();

      UpdateData(FALSE);
}

Then the method to collect the data from the form and update the recordset. (Most of the data retrieval code has been cut out for clarity.)

void CSACView::OnContinue()
{
     GetDlgItemText(IDC_NODENAME, m_pSet->m_NodeName);
     GetDlgItemText(IDC_VENDOR, m_pSet->m_Purchased);
      GetDlgItemText(IDC_AUTHOR, m_pSet->m_Author);
     GetDlgItemText(IDC_SPECCOND, m_pSet->m_SpecCond);

     // Write the record
     m_pSet->Update();

}
ASKER CERTIFIED SOLUTION
hongfeng_wang

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 1 Comment.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros