Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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.

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
Updated 22-Jun-11 0:05am
v2
Comments
[no name] 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

if the data is big it may be better to create a seperate file and only save the link/psth to it. ->performance
 
Share this answer
 
Comments
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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900