WEB开发网
开发学院软件开发VC Ado 实现C++对象的存取 阅读

Ado 实现C++对象的存取

 2006-07-23 11:19:25 来源:WEB开发网   
核心提示: 三、CLine对象的保存void CTestAdoDlg::OnButtonSave(){//m_Listif (!m_bState) return;UpdateData();try{m_pSet->AddNew();m_pSet->PutCollect("name&

三、CLine对象的保存

void CTestAdoDlg::OnButtonSave()
{
  //m_List
  if (!m_bState) return;
  UpdateData();
  try
  {
    m_pSet->AddNew();
    m_pSet->PutCollect("name", _variant_t(m_sName));
    
    //保存图形对象
    CMemFile memFile;
    CArchive ar(&memFile, CArchive::store);
    m_Line.Serialize(ar);
    ar.Close();
    
    DWORD dwSize = memFile.GetLength();
    LPBYTE lpInfo = memFile.Detach();
    
    VARIANT varBLOB;
    SAFEARRAY *psa;
    SAFEARRAYBOUND rgsabound[1];
    
    rgsabound[0].lLbound = 0;
    rgsabound[0].cElements = dwSize;
    
    psa = SafeArrayCreate(VT_UI1, 1, rgsabound);
    for (long i = 0; i < (long)dwSize; i++)
    {
      SafeArrayPutElement (psa, &i, lpInfo++);
    }
    varBLOB.vt = VT_ARRAY | VT_UI1;
    varBLOB.parray = psa;
    m_pSet->GetFields()->GetItem("object")->AppendChunk(varBLOB);
    m_pSet->Update();
    m_List.AddString(m_sName);
  }
  catch(_com_error &e)
  {
    CString str=(char *)e.Description();
    MessageBox(str+"\r保存数据库出问题!","提示",MB_OK|MB_ICONWARNING);
    return ;
  }
  
}    

上一页  1 2 3 4  下一页

Tags:Ado 实现 对象

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接