15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


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





| Вернуться в корень Архива |