Posted on 2003-11-26
I am trying to read a BLOB from a mysql database into a CMemFile and then read the
contents of the CMemFile.
This is my code.............
// deviceDB is the recordset derived class that has attribute m_cal_file declared as CLongBinary
LPSTR buffer = (LPSTR) GlobalLock(deviceDB.m_cal_file.m_hData);
DWORD dwBytesRemaining = memFile.GetLength();
AfxMessageBox(msg); // comes out as 98
UINT nBytesRead = memFile.Read(buf, sizeof(buf));
dwBytesRemaining -= nBytesRead;
strTmp = text;
text.Format("%s%s", strTmp, (LPCSTR)buf);
AfxMessageBox(msg); // always comes out as being 0 - zero!!!
Obviously I am getting stuck in an infinite loop as the number of bytes read is never anything but zero.
How can the CMemFile tell me it has 98 bytes of data and then reads none at a time?
Can anyone help??
Thanks in advance