0

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.

Edited by happygeek: fixed formatting

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by MrSpigot
0

The code I've created doesn't work. Can anyone please review my codes? I think there's something wrong with my codes. Thanks.

Some more info about the problem would be useful. Does it even compile? What happens when it runs?

Please use code tags in future, if it's easier to read you may get more responses.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.