CDaoRecordSet :: Open fails
Di Luo -- photosoft@monmouth.com
Wednesday, November 27, 1996
Environment: VC++ 4.2b, Win 95
I try to open a DaoRecordSet with a SQL
"SELECT * FROM TextInfo". It works fine, However, if I use
"SELECT DISTINCT Title FROM TextInfo" (Title is a field name of the
table TextInfo)
it fails with following message:
"GetRows failed. The requested column is not a member
of this recordset".
....
This is my code segment:
CString strSQL;
strSQL.Format("SELECT DISTINCT Title FROM TextInfo");
CDaoQueryDef qd(pTextInfoTable->m_pDatabase);
qd.Create(NULL, (LPCTSTR)strSQL);
try
{
if(pTextInfoTable->IsOpen())
pTextInfoTable->Close();
pTextInfoTable->Open(&qd);
}
catch(CDaoException *e)
{
......
}
void CDaoTextInfoSet::DoFieldExchange(CDaoFieldExchange* pFX)
{
....
DFX_Text(pFX, _T("[Title]"), m_Title);
......
}
I already tested the above SQL in ACCESS.
Thanks for help.
Di Luo
Jim Leavitt -- jimll@halcyon.com
Friday, November 29, 1996
Di Luo:
>"SELECT DISTINCT Title FROM TextInfo" (Title is a field name of the
>table TextInfo)
Sure looks like it should work. You could try ...
SELECT DISTINCT TextInfo.Title from TextInfo; or
SELECT DISTINCTROW TextInfo.Title from TextInfo.
(DISTINCTROW is an Access SQL addition).
This fully qualifies your field name.
Jim Leavitt
jimll@halcyon.com
----------
| Вернуться в корень Архива
|