Newbie: Passing pointer to Recordset 
Author Message
 Newbie: Passing pointer to Recordset

I'm trying to write what seemed to be a simple Wizard-based
questionnaire, but I've been stuck by this problem for quite a while
now and hope someone can show me where I'm going wrong.

I've derived classes from CPropertySheet and CPropertyPage to create
my Questionnaire, and I'm using a CDaoRecordSet-derived class to
access a Microsoft Access 97 database to read/write records.

My problem appears to be passing the pointer to the recordset from the
recordset into the pages of the wizard.  It works on one page that
creates new records in the database.

Quote:
> void CPage2::OnNewAssesment()
> {
>     if (!m_pSet->IsBOF() && !m_pSet->IsDeleted() && !m_pSet->IsEOF())
>     {
>         UpdateData(TRUE);
>         if (m_pSet->GetEditMode() != dbEditAdd)
>         {
>             m_pSet->Edit();
>         }
>         m_pSet->Update();
>         m_pSet->MoveLast();
>     }
>     m_pSet->SetFieldNull(NULL);
>     m_pSet->AddNew();
>     UpdateData(FALSE);
> }

But it doesn't work on another page when I am using DDX/DDV calls to
transfer data from an existing record into the fields of the property
page.

Quote:
> void CPage3::DoDataExchange(CDataExchange* pDX)
> {
>     CPropertyPage::DoDataExchange(pDX);
>     //{{AFX_DATA_MAP(CPage3)
>     DDX_FieldText(pDX, IDC_BADDRESS, m_pSet->m_Business_Address, m_pSet);
>     DDX_FieldText(pDX, IDC_BPHONE, m_pSet->m_Business_Phone, m_pSet);
>     DDX_FieldText(pDX, IDC_COMPANY, m_pSet->m_Company_Name, m_pSet);
>     DDX_FieldText(pDX, IDC_DATE, m_pSet->m_Date, m_pSet);
>     DDX_FieldText(pDX, IDC_HADDRESS, m_pSet->m_Home_Address, m_pSet);
>     DDX_FieldText(pDX, IDC_HPHONE, m_pSet->m_Home_Phone, m_pSet);
>     DDX_FieldText(pDX, IDC_NAME, m_pSet->m_Name, m_pSet);
>     //}}AFX_DATA_MAP
> }

When it tries to transfer the data it breaks with this error.

Quote:
>  // check to make sure the VTable pointer is valid
>  ASSERT(sizeof(CObject) == sizeof(void*));
>  if (!AfxIsValidAddress(*(void**)pOb, sizeof(void*), FALSE))
>  {
>      TRACE0("ASSERT_VALID fails with illegal vtable pointer.\n");
>      if (AfxAssertFailedLine(lpszFileName, nLine))
>          AfxDebugBreak();
>      return;     // quick escape
>  }

I would really appreciate any help or pointers (no pun intended) that
anyone could give me.

Thanx in advance,
--Alistair


http://www.*-*-*.com/



Tue, 27 Aug 2002 03:00:00 GMT  
 Newbie: Passing pointer to Recordset


Quote:
> I'm trying to write what seemed to be a simple Wizard-based
> questionnaire, but I've been stuck by this problem for quite a while
> now and hope someone can show me where I'm going wrong.

....

I'd put breakpoints in to check the pointer. Your error appeared to indicate
that the pointer got lost, or changed, somewhere - or else that you were
using it after it was freed. You could certainly also put a breakpoint in
the
destructor for your recordset derived class, to make sure the destructor
isn't called before you think it is...



Tue, 27 Aug 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Newbie: Passing pointer to Recordset

2. passing RecordSet pointers

3. newbie pointer to structure passing.

4. Newbie question: Pointer to an array and passing it into a function

5. Passing by Reference Or Passing by Pointer

6. passing a pointer to a pointer

7. Passing pointers to arrays of pointers....

8. Passing a Pointer to Pointer to an Interface

9. how to call MyFunction(VARIANT* pRs) passing in ADO recordset

10. Has anyone beenable to pass recordset's thru interfaces in C++

11. Passing Recordsets through COM

12. passing recordset

 

 
Powered by phpBB® Forum Software