Go4Expert

Go4Expert (http://www.go4expert.com/)
-   MFC (http://www.go4expert.com/forums/mfc/)
-   -   loading and storing a CLongBinary data (http://www.go4expert.com/forums/loading-storing-clongbinary-data-t16003/)

Priya-87 30Jan2009 16:29

loading and storing a CLongBinary data
 
Hi
I am havin a problem in loading and storing a CLongBinary data from and to a database.
I am using MS access database and I am trying to store a binary form of Cstring data in to the database field which is of type oleobject.
This is the part of my code where i am trying to store.
Please help me out this code :

trial_obj.Open(); // MFC Wizard class created in vc++
trial_obj.AddNew();
pVoid = NULL;
len = str.GetLength()+1;
trial_obj.m_data2.m_hData = ::GlobalAlloc(GPTR,len); // trial_obj.m_data2 is a oleobject field in database
pVoid = ::GlobalLock(trial_obj.m_data2.m_hData);
::memcpy(pVoid,(LPSTstr.GetData(),len);
::GlobalUnlock(trial_obj.m_data2.m_hData);
trial_obj.m_data2.m_dwDataLength =::GlobalSize(trial_obj.m_data2.m_hData);
trial_obj.Update();
trial_obj.Close();


All times are GMT +5.5. The time now is 04:44.