Click here to Skip to main content
13,096,858 members (85,281 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Am using the following code to get the blob data from the image file stored in the local disk.. I want to save that blob data into the blob field of database.

<code>CLongBinary m_BLOBImage;
	CFileStatus fileStatus;
        CString m_BLOBName = strfile.GetFileTitle();
        m_BLOBImage.m_dwDataLength = fileStatus.m_size;
	SIZE_T dwbytes=(SIZE_T)fileStatus.m_size;
        HGLOBAL hGlobal		= GlobalAlloc(GPTR,dwbytes);
        m_BLOBImage.m_hData = GlobalLock(hGlobal);

How to use the CRecordSet to save this blob data found in m_BlobImage.m_hData to the blob field in the database.
Posted 20-Jun-11 18:28pm
Updated 22-Jun-11 0:05am
SanjeevSingh 21-Jun-11 2:20am
is it that you want to save Image to Sql table??
Gokulnath007 21-Jun-11 3:21am
yes, dbImages.m_BLOBImage.m_hData contains the binary data. I want to store this into the MYSQL blob field.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

if the data is big it may be better to create a seperate file and only save the link/psth to it. ->performance
Gokulnath007 21-Jun-11 9:40am
m_BLOBImage.m_hData has the blob data, the only thing is to save this to the blob field of the MYSQL Database.
KarstenK 21-Jun-11 9:50am
why dont you copy the file somewhere in a storage which belongs to the database? This is common practice in database managment systems.

Dont ferget that it raises the speed because that data isnt in the db so it isnt transfered in operations.
Gokulnath007 22-Jun-11 0:54am
I want to save the blob data with out making any change should be saved in the blob field of the MYSQL Database.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.170813.1 | Last Updated 22 Jun 2011
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100