Save BLOB data using CRecordSet and CLongBinary 
Author Message
 Save BLOB data using CRecordSet and CLongBinary

Hi there,

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;
try
{
        recordSet.Open();
        recordSet.AddNew();

        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);
        GlobalUnlock(recordSet.m_PHOTO.m_hData);
        recordSet.SetFieldDirty(&recordSet.m_PHOTO, TRUE);
        recordSet.SetFieldNull(&recordSet.m_PHOTO, FALSE);
        recordSet.Update();

Quote:
}

When I debug the program and trace down the CRecordSet::Update
function, the error happened in CRecordSet::SendLongBinaryData of
VC98\MFC\SRC\DBCORE.cpp.

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.

Any clue?

Thanks in advance,
Frank



Wed, 07 Apr 2004 03:46:20 GMT  
 Save BLOB data using CRecordSet and CLongBinary


Wed, 18 Jun 1902 08:00:00 GMT  
 Save BLOB data using CRecordSet and CLongBinary
The database server is Oracle 8.0.5, and the table for testing is very
simple. The table structure is showing as follows:
// create table DUMMYTABLE(
    FIRSTNAME    VARCHAR2(50),
    LASTNAME     VARCHAR2(50),
    PHOTO        BLOB
//);

Any suggestion and hints would be really appreciated.

Feipeng

Quote:

> Hi there,

> 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;
> try
> {
>    recordSet.Open();
>    recordSet.AddNew();

>    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);
>    GlobalUnlock(recordSet.m_PHOTO.m_hData);
>    recordSet.SetFieldDirty(&recordSet.m_PHOTO, TRUE);
>    recordSet.SetFieldNull(&recordSet.m_PHOTO, FALSE);
>    recordSet.Update();
> }

> When I debug the program and trace down the CRecordSet::Update
> function, the error happened in CRecordSet::SendLongBinaryData of
> VC98\MFC\SRC\DBCORE.cpp.

> 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.

> Any clue?

> Thanks in advance,
> Frank



Wed, 07 Apr 2004 11:50:47 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Using CLongBinary To update BLOBs

2. Using CLongBinary objects for retrieving BLOB from database

3. Blob using CLongBinary

4. Using CLongBinary objects for retrieving BLOB from database

5. Bug in MFC v.5 - CRecordset::Open using CLongBinary and GetDefaultSQL() override

6. SERIOUS PROBLEM in using LOBs of ORACLE with VC's CRecordset/CLongBinary

7. Bug in MFC v.5 - CRecordset::Open using CLongBinary and GetDefaultSQL() override

8. Saving and retrieving Ole-Automation objects from Dao and MFC using CLongBinary class

9. Saving and retrieving Ole-Automation objects from Dao and MFC using CLongBinary class

10. Using CDatabase::ExecuteSQL vs subclassing CRecordset for inserts (of BLOBs, in particular)

11. Adding BLOB's/CLongBinary not working

12. Storing/Retrieving null blobs through CLongBinary objects?

 

 
Powered by phpBB® Forum Software