Error while retrieving data with CRecordSet
Dear all,
I am creating a MFC dialog based application in VC++ 6.0.
Database is MS-Access.
Driver is ODBC.
Platform: WIN NT.
Description of my table is as follows.
Table Name - Machine
Machine ID (Primary key)- Number
Machine Name - Text
Machine Type - Text
Clamping Tonnage - Number
Injection Force - Number
StdMachineSet is the object of class derived from CrecordSet.
StdMachineSet.Open(CRecordset::dynaset,
"SELECT DISTINCT [Machine Name] FROM Machine",
CRecordset::readOnly);
It gives me the error : Error retreiving record.
When I changed the query to
StdMachineSet.Open(CRecordset::dynaset,
"SELECT * FROM Machine",
CRecordset::readOnly);
It works fine.
What might be the problem?
Regards,
Anand.
Re: Error while retrieving data with CRecordSet
Just off the top of my head:
SELECT DISTINCT returns a static recordset. If you try
CRecordset::snapshot instead of CRecordset::dynaset
your query might succeed.
HTH,
Peter
Re: Error while retrieving data with CRecordSet
Hi Peter,
It didn't work with CRecordset::snapshot also.
Anand.
Re: Error while retrieving data with CRecordSet
OK,
How does your DoFieldExchange function look?
Regards,
Peter
Re: Error while retrieving data with CRecordSet
void CMachineSet::DoFieldExchange(CFieldExchange* pFX)
{
//{{AFX_FIELD_MAP(CMachineSet)
pFX->SetFieldType(CFieldExchange::outputColumn);
RFX_Int(pFX, _T("[MachineID]"), m_MachineID);
RFX_Text(pFX, _T("[Machine Name]"), m_Machine_Name);
RFX_Text(pFX, _T("[Machine Type]"), m_Machine_Type);
RFX_Double(pFX, _T("[Clamping Tonnage]"), m_Clamping_Tonnage);
RFX_Double(pFX, _T("[Injection Force]"), m_Injection_Force);
//}}AFX_FIELD_MAP
}
Regards,
Anand.
Re: Error while retrieving data with CRecordSet
There's the problem: You have only the [Machine Name] field in your recordset. The Field exchange function expects all the fields of your table.
Regards,
Peter