Click here to Skip to main content
Rate this: bad
good
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;
	strfile.GetStatus(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);
	strfile.Read(dbImages.m_BLOBImage.m_hData,(UINT)fileStatus.m_size);
 
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
Edited 22-Jun-11 0:05am
v2
Comments
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
good
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
  Permalink  
Comments
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 Sergey Alexandrovich Kryukov 888
1 OriginalGriff 420
2 CPallini 275
3 George Jonsson 226
4 Richard Deeming 145
0 OriginalGriff 5,450
1 CPallini 4,500
2 Sergey Alexandrovich Kryukov 4,482
3 George Jonsson 3,057
4 Gihan Liyanage 2,445


Advertise | Privacy | Mobile
Web01 | 2.8.140916.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