Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: VC8.0
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.
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 19:28pm
Edited 22-Jun-11 1:05am
SanjeevSingh at 21-Jun-11 2:20am
is it that you want to save Image to Sql table??
Gokulnath007 at 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 at 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 at 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 at 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
0 OriginalGriff 381
1 Sergey Alexandrovich Kryukov 245
2 Marcin Kozub 225
3 Praneet Nadkar 217
4 /\jmot 189
0 OriginalGriff 8,284
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,614
3 Maciej Los 4,989
4 Manas Bhardwaj 4,986

Advertise | Privacy | Mobile
Web01 | 2.8.1411023.1 | Last Updated 22 Jun 2011
Copyright © CodeProject, 1999-2014
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