1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

loading and storing a CLongBinary data

Discussion in 'MFC' started by Priya-87, Jan 30, 2009.

  1. Priya-87

    Priya-87 New Member

    Joined:
    Jan 30, 2009
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    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();
     

Share This Page