I can't retrieve the data from my "file.mdb" file. Below is the code I created:
code = m_Code.Mid(beginIndex, endIndex);
CDaoDatabase database;
CDaoRecordset recordset(&database);
CString lpszFile = "C:/file.mdb";
database.Open(lpszFile, FALSE, TRUE, _T(""));
recordset.Open(AFX_DAO_USE_DEFAULT_TYPE,"SELECT * FROM KeyID", 0);
COleVariant olevar;
while(!recordset.IsEOF());
{
olevar.ChangeType(VT_BSTR, NULL);
recordset.GetFieldValue("ID", olevar);
CString fieldValue = (LPCSTR)olevar.pbstrVal;
if(code == fieldValue)
{
AfxMessageBox(fieldValue);
}
recordset.MoveNext();
}
The code I've created doesn't work. Can anyone please review my codes? I think there's something wrong with my codes. Thanks.