
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