Save BLOB data using CRecordSet and CLongBinary
I got a weird problem when I tried to save BLOB data using CRecordSet.
Everytime it just throws an access violation error and my application
is dead. However, the data was actually saved in database, and I can
even retrieve all data successfully next time.
The following code is what I used to test.
int nLength = 10;
recordSet.m_PHOTO.m_dwDataLength = nLength;
recordSet.m_PHOTO.m_hData = GlobalAlloc(GPTR, 50);
hGlobal = GlobalLock(recordSet.m_PHOTO.m_hData);
memcpy(hGlobal, "12345678901234567890", nLength);
When I debug the program and trace down the CRecordSet::Update
function, the error happened in CRecordSet::SendLongBinaryData of
In the "while" loop, it calls ::SQLPutData to put my data in database,
then it calls ::SQLParamData to see if there is any more data. This
the exact place I got error.
Thanks in advance,