Hello,

VC++6.0 Prof, Win98

I am a new VC++ programmer looking for help.

I am trying to open a recordset on the fly and read a value from the first record. This apparently
necessitates using GetFieldValue with a COleVariant variable. My code is as follows:-

CDaoDatabase* pDB = new CDaoDatabase;
try
{
pDB->Open("D:\\Vb4&5prg\\Experiment\\Mail1.mdb");
}
catch(CDaoException* e)
{
AfxMessageBox(e->m_pErrorInfo->m_strDescription, MB_ICONEXCLAMATION);
e->Delete();
}

CDaoRecordset pRS(pDB);
CString mText = "Select * from Folders";
try
{
pRS.Open(AFX_DAO_USE_DEFAULT_TYPE, mText,0);
}
catch(CDaoException* e)
{
AfxMessageBox(e->m_pErrorInfo->m_strDescription, MB_ICONEXCLAMATION);
e->Delete();
}
pRS.MoveFirst();
COleVariant mVar;
int i = 1;
mVar = pRS.GetFieldValue(i);
mText = mVar;
AfxMessageBox(mText);
pDB->Close();
delete pDB;



The above fails on the attempt to pass the COleVariant value into a CString. I would be grateful for code
examples on how to convert a COleVariant into something that can be readily used, preferably a CString.
If there are any other errors in my code, I'd also be glad to know.

Hoping for help from all you experts,

TrimTrom

----------------------------------
Email: [email protected]
Surrey, England
----------------------------------