Relative Newbie Question: DAO and Property Sheet Wizard 
Author Message
 Relative Newbie Question: DAO and Property Sheet Wizard

I'm pretty new at MFC programming so forgive me if this is obvious.

Using VC++6 I'm trying to create a questionnaire in the form of a wizard.
I've managed to put together the code for drawing the wizard, which works
fine.  Now I am trying to add the database functionality to get the data
from the controls in the wizard and am having a pretty fundamental problem.

Following tutorials on the net and in books I have created a class for the
wizard itself and classes for each page of the wizard.  I a just added the
DaoRecordSet-derived class.  But now when I try to access the recordset from
one of the pages... well this happens.

Here's the code...

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

This is the result...

Quote:
> Page2.cpp
> ...Page2.cpp(61) : error C2065: 'm_pSet' : undeclared identifier
> ...Page2.cpp(61) : error C2227: left of '->IsBOF' must point to
class/struct/union
> ...Page2.cpp(61) : error C2227: left of '->IsDeleted' must point to

class/struct/union
 > ...Page2.cpp(61) : error C2227: left of '->IsEOF' must point to
class/struct/union
Quote:
> ...Page2.cpp(64) : error C2227: left of '->GetEditMode' must point to
class/struct/union
> ...Page2.cpp(66) : error C2227: left of '->Edit' must point to
class/struct/union
> ...Page2.cpp(68) : error C2227: left of '->Update' must point to
class/struct/union
> ...Page2.cpp(69) : error C2227: left of '->MoveLast' must point to
class/struct/union
> ...Page2.cpp(71) : error C2227: left of '->SetFieldNull' must point to
class/struct/union
> ...Page2.cpp(72) : error C2227: left of '->AddNew' must point to

class/struct/union

I guess I am missing a link somewhere between the RecordSet and the
individual Pages or the Wizard class, but I can't figure it out myself.

If anyone could help or even direct me to a website that might help (i.e.
have an example of a Dao-accessing wizard), I'd be really grateful.

-- Alistair

"Everything must end; meanwhile we must amuse ourselves"
-- Voltaire


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



Wed, 24 Jul 2002 03:00:00 GMT  
 Relative Newbie Question: DAO and Property Sheet Wizard

Quote:

> > ...Page2.cpp(61) : error C2065: 'm_pSet' : undeclared identifier
> > ...Page2.cpp(61) : error C2227: left of '->IsBOF' must point to
> class/struct/union
> I guess I am missing a link somewhere between the RecordSet and the
> individual Pages or the Wizard class, but I can't figure it out myself.

> If anyone could help or even direct me to a website that might help (i.e.
> have an example of a Dao-accessing wizard), I'd be really grateful.

This doesn't have anything to do with Dao or wizards, it has to do with the
basics of C++.  To access a member variable or function in another object you
must specify the object.  Inside the recordset class you can use m_pSet, but
from other classes you must use a reference like rs.m_pSet or a pointer like
prs->m_pSet.  When you construct or initialize the page object pass it a pointer
to the class it will need to access.

--
Scott McPhillips [VC++ MVP]



Wed, 24 Jul 2002 03:00:00 GMT  
 Relative Newbie Question: DAO and Property Sheet Wizard
If m_pSet is supposed to be a CRecordset *, it apparently isn't declared in your
header that way.  Do you have this variable declaration in the CPage2 class?
        CRecordset * m_pSet ;

Also, do you have #include <afxdb.h> in your Cpp file, or in the StdAfx.H?



Wed, 24 Jul 2002 03:00:00 GMT  
 Relative Newbie Question: DAO and Property Sheet Wizard
Er...

m_pSet .. undeclared identifier is giving rise to every other problem. You
don't have a variable called m_pSet in your CPage2 class or probably
anywhere else for that matter. If the compiler cannot determine what m_pSet
is then it can't determine the methods or anything else. Just for the hell
of it declare

CDaoRecordset *m_pSet in CPage2 and you'll see all your errors disappear.
However, that was just the proof of the pudding. Now remove the declaration
which will cause you countless run-time errors because it is not initialised
etc. etc. You have a fair amount of work to do to your code.

For instance if you call your derived class Edit() and then Update() without
actually changing any values of the recordset what do you expect to achieve
?
Your updating a record with itself - No change !!


Quote:
> I'm pretty new at MFC programming so forgive me if this is obvious.

> Using VC++6 I'm trying to create a questionnaire in the form of a wizard.
> I've managed to put together the code for drawing the wizard, which works
> fine.  Now I am trying to add the database functionality to get the data
> from the controls in the wizard and am having a pretty fundamental
problem.

> Following tutorials on the net and in books I have created a class for the
> wizard itself and classes for each page of the wizard.  I a just added the
> DaoRecordSet-derived class.  But now when I try to access the recordset
from
> one of the pages... well this happens.

> Here's the code...

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

> This is the result...

> > Page2.cpp
> > ...Page2.cpp(61) : error C2065: 'm_pSet' : undeclared identifier
> > ...Page2.cpp(61) : error C2227: left of '->IsBOF' must point to
> class/struct/union
> > ...Page2.cpp(61) : error C2227: left of '->IsDeleted' must point to
> class/struct/union
>  > ...Page2.cpp(61) : error C2227: left of '->IsEOF' must point to
> class/struct/union
> > ...Page2.cpp(64) : error C2227: left of '->GetEditMode' must point to
> class/struct/union
> > ...Page2.cpp(66) : error C2227: left of '->Edit' must point to
> class/struct/union
> > ...Page2.cpp(68) : error C2227: left of '->Update' must point to
> class/struct/union
> > ...Page2.cpp(69) : error C2227: left of '->MoveLast' must point to
> class/struct/union
> > ...Page2.cpp(71) : error C2227: left of '->SetFieldNull' must point to
> class/struct/union
> > ...Page2.cpp(72) : error C2227: left of '->AddNew' must point to
> class/struct/union

> I guess I am missing a link somewhere between the RecordSet and the
> individual Pages or the Wizard class, but I can't figure it out myself.

> If anyone could help or even direct me to a website that might help (i.e.
> have an example of a Dao-accessing wizard), I'd be really grateful.

> -- Alistair

> "Everything must end; meanwhile we must amuse ourselves"
> -- Voltaire


> http://www.amcmillan.f9.co.uk



Wed, 24 Jul 2002 03:00:00 GMT  
 Relative Newbie Question: DAO and Property Sheet Wizard
On Sat, 5 Feb 2000 23:30:35 -0000, "Robert Quirk"

Sorry I don't think I was clear. The code I included was just the code
I actually added myself, I didn't include the code that ClassWizard
generated itself.  Was this a mistake?

Also the calls to Edit() and Update() are just there to ensure that
any recently entered user data isn't lost before creating a New
record.  At least that's the idea.

Anyway, like you said I had missed out the declaration of the m_pSet
pointer in the CPage2 class.  However when I add it, the program does
compile but crashes when I click the button that references
OnNewAssesment.

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

Is there somewhere else aside from the Recordset-derived class and the
PropertyPage-derived classes that I should declare m_pSet?

Something else that is a symptom of my lack of experience...  before
when I was adding DAO commands to another program, when I went to Add
Data Member to a Control ID in the Data Member section of ClassWizard,
I would get a drop-list of available data, but as I'm building this
program I don't.

As before, any help is gratefully accepted.

-- Alistair McMillan

Quote:
>Er...

>m_pSet .. undeclared identifier is giving rise to every other problem. You
>don't have a variable called m_pSet in your CPage2 class or probably
>anywhere else for that matter. If the compiler cannot determine what m_pSet
>is then it can't determine the methods or anything else. Just for the hell
>of it declare

>CDaoRecordset *m_pSet in CPage2 and you'll see all your errors disappear.
>However, that was just the proof of the pudding. Now remove the declaration
>which will cause you countless run-time errors because it is not initialised
>etc. etc. You have a fair amount of work to do to your code.
>For instance if you call your derived class Edit() and then Update() without
>actually changing any values of the recordset what do you expect to achieve
>?
>Your updating a record with itself - No change !!


>> I'm pretty new at MFC programming so forgive me if this is obvious.

>> Using VC++6 I'm trying to create a questionnaire in the form of a wizard.
>> I've managed to put together the code for drawing the wizard, which works
>> fine.  Now I am trying to add the database functionality to get the data
>> from the controls in the wizard and am having a pretty fundamental
>problem.

>> Following tutorials on the net and in books I have created a class for the
>> wizard itself and classes for each page of the wizard.  I a just added the
>> DaoRecordSet-derived class.  But now when I try to access the recordset
>from
>> one of the pages... well this happens.

>> Here's the code...

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

>> This is the result...

>> > Page2.cpp
>> > ...Page2.cpp(61) : error C2065: 'm_pSet' : undeclared identifier
>> > ...Page2.cpp(61) : error C2227: left of '->IsBOF' must point to
>> class/struct/union
>> > ...Page2.cpp(61) : error C2227: left of '->IsDeleted' must point to
>> class/struct/union
>>  > ...Page2.cpp(61) : error C2227: left of '->IsEOF' must point to
>> class/struct/union
>> > ...Page2.cpp(64) : error C2227: left of '->GetEditMode' must point to
>> class/struct/union
>> > ...Page2.cpp(66) : error C2227: left of '->Edit' must point to
>> class/struct/union
>> > ...Page2.cpp(68) : error C2227: left of '->Update' must point to
>> class/struct/union
>> > ...Page2.cpp(69) : error C2227: left of '->MoveLast' must point to
>> class/struct/union
>> > ...Page2.cpp(71) : error C2227: left of '->SetFieldNull' must point to
>> class/struct/union
>> > ...Page2.cpp(72) : error C2227: left of '->AddNew' must point to
>> class/struct/union

>> I guess I am missing a link somewhere between the RecordSet and the
>> individual Pages or the Wizard class, but I can't figure it out myself.

>> If anyone could help or even direct me to a website that might help (i.e.
>> have an example of a Dao-accessing wizard), I'd be really grateful.

>> -- Alistair

>> "Everything must end; meanwhile we must amuse ourselves"
>> -- Voltaire


>> http://www.amcmillan.f9.co.uk



Fri, 26 Jul 2002 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Relative Newbie Question: DAO and Property Sheet Wizard

2. Creating Property Sheets and Property Pages w/o the Class Wizard

3. Property Sheet within a Property Sheet

4. Property sheet from property sheet

5. Q: Property sheet within a property sheet

6. please help with wizard and property sheet

7. Disable NEXT button a wizard property sheet

8. Help Button on Property Sheet Wizard

9. Property Sheet Wizards

10. Property sheets in wizard mode

11. Property Sheet, wizard, context-sensitive help

12. Icon and property sheet wizard

 

 
Powered by phpBB® Forum Software