Click here to Skip to main content
15,891,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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
Updated 10-Jan-13 18:05pm
v2
Comments
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;
bmp.Attach((BITMAPINFOHEADER*)(pImg));
BITMAPINFOHEADER *img=bmp.BI();
bitmap_type tmp(new ClSimpleBitmap(bmp));
GLB_m_pSrcBmpScanner.Swap(tmp);

1 solution

C++
void CSaveImageDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Control(pDX,IDC_Image,m_Image);//m_Image is CStatic
}

void CSaveImageDlg::OnBnClickedButton1()
{
CDaoDatabase m_database;
	CDaoRecordset  m_recordset;
	m_database.Open(_T("C:\\dabasename.mdb"),TRUE,FALSE,_T(""));
	m_recordset.m_pDatabase = &m_database;
	m_recordset.Open(AFX_DAO_USE_DEFAULT_TYPE,_T("select * from Table1"), 0);

		m_recordset.AddNew();
		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_recordset.SetFieldValue(_T("Image"),oleImage);
		m_recordset.Update();

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

}
 
Share this answer
 
Comments
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)



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