Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VS2008 MFC VC++
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 1:40am
Edited 10-Jan-13 19:05pm
v2
Comments
Sandeep Mewara at 10-Jan-13 9:00am
   
Ok. And what happened when you tried to implement what you want?
Member 7909353 at 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

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

Solution 1

 

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();
 
}
  Permalink  
Comments
Member 7909353 at 28-Jan-13 0:58am
   
It does not show image in ms access table.
Member 7909353 at 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
0 Sergey Alexandrovich Kryukov 555
1 Kornfeld Eliyahu Peter 409
2 Maciej Los 369
3 DamithSL 196
4 OriginalGriff 188
0 OriginalGriff 6,353
1 DamithSL 4,854
2 Maciej Los 4,466
3 Kornfeld Eliyahu Peter 4,058
4 Sergey Alexandrovich Kryukov 3,897


Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 11 Jan 2013
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