problem in 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();

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories