Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CRecordset added into a project - I get erros

Status
Not open for further replies.

mwr412

Programmer
Jan 9, 2002
23
0
0
US
I inserted the follwing code into my project using class wizard, I get 97 erros when it compiles, starting with:

F:\Mike\Ams7\MainMenu\RecordSetAR.h(14) : error C2504: 'CRecordset' : base class undefined

The CCP file:

// RecordSetAR.cpp : implementation file
//

#include "stdafx.h"
#include "MainMenu.h"
#include "RecordSetAR.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CRecordSetAR

IMPLEMENT_DYNAMIC(CRecordSetAR, CRecordset)

CRecordSetAR::CRecordSetAR(CDatabase* pdb)
: CRecordset(pdb)
{
//{{AFX_FIELD_INIT(CRecordSetAR)
m_RECORD_NUMB = 0;
m_TYPE = _T("");
m_RECORD_STATUS = _T("");
m_PRINT_STATUS = _T("");
m_CHECK_NUMB = 0;
m_PAY_TO_THE_ORDER = _T("");
m_DESCRIPTION = _T("");
m_AMOUNT = _T("");
m_REFERENCE_NUMB = _T("");
m_PO_NUMB = _T("");
m_GL_CREDIT = _T("");
m_GL_DEBIT1 = _T("");
m_DEBIT_AMT1 = 0;
m_GL_DEBIT2 = _T("");
m_DEBIT_AMT2 = 0;
m_GL_DEBIT3 = _T("");
m_DEBIT_AMT3 = 0;
m_GL_DEBIT4 = _T("");
m_DEBIT_AMT4 = 0;
m_nFields = 20;
//}}AFX_FIELD_INIT
m_nDefaultType = dynaset;
}


CString CRecordSetAR::GetDefaultConnect()
{
return _T("ODBC;DSN=MS Access 97 Database");
}

CString CRecordSetAR::GetDefaultSQL()
{
return _T("[CheckFile]");
}

void CRecordSetAR::DoFieldExchange(CFieldExchange* pFX)
{
//{{AFX_FIELD_MAP(CRecordSetAR)
pFX->SetFieldType(CFieldExchange::eek:utputColumn);
RFX_Long(pFX, _T("[RECORD_NUMB]"), m_RECORD_NUMB);
RFX_Text(pFX, _T("[TYPE]"), m_TYPE);
RFX_Text(pFX, _T("[RECORD_STATUS]"), m_RECORD_STATUS);
RFX_Text(pFX, _T("[PRINT_STATUS]"), m_PRINT_STATUS);
RFX_Long(pFX, _T("[CHECK_NUMB]"), m_CHECK_NUMB);
RFX_Date(pFX, _T("[CHECK_DATE]"), m_CHECK_DATE);
RFX_Text(pFX, _T("[PAY_TO_THE_ORDER]"), m_PAY_TO_THE_ORDER);
RFX_Text(pFX, _T("[DESCRIPTION]"), m_DESCRIPTION);
RFX_Text(pFX, _T("[AMOUNT]"), m_AMOUNT);
RFX_Text(pFX, _T("[REFERENCE_NUMB]"), m_REFERENCE_NUMB);
RFX_Text(pFX, _T("[PO_NUMB]"), m_PO_NUMB);
RFX_Text(pFX, _T("[GL_CREDIT]"), m_GL_CREDIT);
RFX_Text(pFX, _T("[GL_DEBIT1]"), m_GL_DEBIT1);
RFX_Long(pFX, _T("[DEBIT_AMT1]"), m_DEBIT_AMT1);
RFX_Text(pFX, _T("[GL_DEBIT2]"), m_GL_DEBIT2);
RFX_Long(pFX, _T("[DEBIT_AMT2]"), m_DEBIT_AMT2);
RFX_Text(pFX, _T("[GL_DEBIT3]"), m_GL_DEBIT3);
RFX_Long(pFX, _T("[DEBIT_AMT3]"), m_DEBIT_AMT3);
RFX_Text(pFX, _T("[GL_DEBIT4]"), m_GL_DEBIT4);
RFX_Long(pFX, _T("[DEBIT_AMT4]"), m_DEBIT_AMT4);
//}}AFX_FIELD_MAP
}

/////////////////////////////////////////////////////////////////////////////
// CRecordSetAR diagnostics

#ifdef _DEBUG
void CRecordSetAR::AssertValid() const
{
CRecordset::AssertValid();
}

void CRecordSetAR::Dump(CDumpContext& dc) const
{
CRecordset::Dump(dc);
}
#endif //_DEBUG

The .h file:

#if !defined(AFX_RECORDSETAR_H__62FD7183_09D1_11D6_B03F_0040F6B4AC3D__INCLUDED_)
#define AFX_RECORDSETAR_H__62FD7183_09D1_11D6_B03F_0040F6B4AC3D__INCLUDED_

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// RecordSetAR.h : header file
//

/////////////////////////////////////////////////////////////////////////////
// CRecordSetAR recordset

class CRecordSetAR : public CRecordset
{ <<<<<<<<<- This is were the first erros is at?!
public:
CRecordSetAR(CDatabase* pDatabase = NULL);
DECLARE_DYNAMIC(CRecordSetAR)

// Field/Param Data
//{{AFX_FIELD(CRecordSetAR, CRecordset)
long m_RECORD_NUMB;
CString m_TYPE;
CString m_RECORD_STATUS;
CString m_PRINT_STATUS;
long m_CHECK_NUMB;
CTime m_CHECK_DATE;
CString m_PAY_TO_THE_ORDER;
CString m_DESCRIPTION;
CString m_AMOUNT;
CString m_REFERENCE_NUMB;
CString m_PO_NUMB;
CString m_GL_CREDIT;
CString m_GL_DEBIT1;
long m_DEBIT_AMT1;
CString m_GL_DEBIT2;
long m_DEBIT_AMT2;
CString m_GL_DEBIT3;
long m_DEBIT_AMT3;
CString m_GL_DEBIT4;
long m_DEBIT_AMT4;
//}}AFX_FIELD


// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CRecordSetAR)
public:
virtual CString GetDefaultConnect(); // Default connection string
virtual CString GetDefaultSQL(); // Default SQL for Recordset
virtual void DoFieldExchange(CFieldExchange* pFX); // RFX support
//}}AFX_VIRTUAL

// Implementation
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_RECORDSETAR_H__62FD7183_09D1_11D6_B03F_0040F6B4AC3D__INCLUDED_)
------------------------
I've reached my witts-end with this...help......Is there somthing that needs to be added to one of the other project fiels...the documentation I have doesn't say anything about modifying other files???
 
Perhaps your header file also needs this added at the top:

#include &quot;stdafx.h&quot;
 
I'm a novice in ADO programming in VC++. I have now a problem that I have
tried to resolved but I failed.
If I open a Access DB by command:
Recordset.Open(SQL statement, Connection,...)
Is will be OK
But If I open by the way:
Command.ActiveConnection = Connection;// this was initialized
Command.CommandText = My SQL Statement;
Recordset = Command.Execute(...)
It failed, the recordCount = -1, I use try..catch to trap error, but I
can't.
If you know what is the core of the problem, or how to correct the
situation, please feedback to me
 
Yes, afxdb.h was the solution...now this brings up a question...since I used Class Wizard to insert the CRecordset class way did it [Class Wizzard] not add this header file for itself...Is the answer to this burried deep inside the bowels of Microsoft???? I have run into several similar situations where Class Wizard did not seen to do everything that it ought to have in my opion!!!!
 
Wizards will never replace astute coders - there are too many &quot;what if&quot; situations in programming.
 
Incidentally, #include &quot;stdafx.h&quot; also works since it generally includes &quot;afxdb.h&quot;, among a lot of other things.

On the subject of Class Wizard &quot;doing what it's supposed to&quot;, I've sometimes had it &quot;clobber&quot; parts of my MessageMap. Very irritating! Fortunately, I use SourceSafe, so I can &quot;Show Differences&quot; to restore the stuff it removed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top