Click here to Skip to main content
13,503,505 members
Rate this:
Please Sign up or sign in to vote.
See more: , +
Hello all,
I have a (const BYTE* pimg/bmp) file.
I have table named "ImageOLEs"
Field names:
1.UserName-text (required field)
2. ImageItem - OLE Object etc.

I have to save .bmp file in MS Access database using VC++.

I have a project Employee Management System in which the database is centralized and i need to save photo of an employee in databse table from VC++ interface. I am able to insert other information like personal info.Project and job info. but how to store photo of an employee in databse so that it can be retreived from any where in centralized databse.

I want to save above file in ImageItem column as oleobject.

Thanks for in Advance for any advice.
Posted 10-Jan-13 0:40am
Updated 10-Jan-13 18:05pm
Sandeep Mewara 10-Jan-13 9:00am
Ok. And what happened when you tried to implement what you want?
Member 7909353 10-Jan-13 23:58pm
Right now I am saving image in a folder and path of image in database.
HWND wnd=::GetDlgItem(GetSafeHwnd(), IDC_DetectImage);
//HWND wnd=::GetDlgItem(m_hWnd, IDC_IMAGE);
DRM_EXP_THROW_0(((NULL != wnd) && ::IsWindow(wnd)),Drm::CXSystemSpecificException);
Drm::utilities::ClSimpleBitmap bmp;
bitmap_type tmp(new ClSimpleBitmap(bmp));

1 solution

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

Solution 1

void CSaveImageDlg::DoDataExchange(CDataExchange* pDX)
	DDX_Control(pDX,IDC_Image,m_Image);//m_Image is CStatic

void CSaveImageDlg::OnBnClickedButton1()
CDaoDatabase m_database;
	CDaoRecordset  m_recordset;
	m_recordset.m_pDatabase = &m_database;
	m_recordset.Open(AFX_DAO_USE_DEFAULT_TYPE,_T("select * from Table1"), 0);

		CImage Image;
		HBITMAP h_bit=m_Image.GetBitmap();
		CLongBinary clb;
		clb.m_hData = h_bit;
		clb.m_dwDataLength = ::GlobalSize(h_bit);
		COleVariant oleImage(clb);

		//		m_database.Execute();//  .ExecuteSQL(cmd);

Member 7909353 28-Jan-13 0:58am
It does not show image in ms access table.
Member 7909353 30-Jan-13 0:33am
When I open image from ms access it shows a message as
The OLE object is empty.

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.180417.1 | Last Updated 11 Jan 2013
Copyright © CodeProject, 1999-2018
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