Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. problem with adding and deleting ADO,also needs resources

problem with adding and deleting ADO,also needs resources

Scheduled Pinned Locked Moved Database
helpc++tutorialquestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kingori
    wrote on last edited by
    #1

    hi; i new in MFC and i have a problem with adding and deleting but basically i can attribute my problem to lack of proper tutorials on the same. ANy site i try to get tutorials i end up with getting complex stuff posted by Gurus tryiong to implement not the usual basic works that am in need of so i have been tring to understand the whole concept by following one simple code example i have and so in that connection if you know a site i can get real introduction tutorials to ADO in MFC i will appreciate but in the mean time help me get thru this problem at hand(my name is king'ori from kenya); I want to add supplierid (not null primary key) and suppliername(not null) to the SUPPLIERS table (which i have alreaady created); so i have included the adofields.h in my project..,done the ::initialization, the opening() plus i have these functions void MyView:: RefreshSupplier() { if(p_rsSupplier->BOFILE || p_rsSupplierEOFILE) return; m_strSupplierName =(const char*)_bstr_t(FieldValue(p_rsSupplier,"suppliername"); m_lSupplierID = long(FieldValue(p_rsSupplier,"supplierID")); UpdateData(FALSE); } vooid MyView:: UpdateSupplier() { if(p_rsSupplier->BOFILE || p_rsSupplier->EOFILE) retirn; CString strSupplier; long lsupplier; UpgateData(); if(lSupplier != m_lSupplierID) FieldValue(p_rsSupplier,"supplierid",m_lSupplierID); if(strSupplier != m_strSupplierName) FieldValue(p_rsSupplier,"suppliername",m_strSuppliername); } void MyView::BlankSupplier() { m_lSupplierID = 0; m_strSupplierName = _T(" "); } problem comes i dont understand the adding flow,- for instance why do you have to blank the recordset? what comes first p_rsSupplier->Addnew() or is it UpdateSupplier() and why; this is not working void MyView::AddSupplier() { BlankSupplier(); //why this and my fields are not null? p_rsSupplier->AddNew(); UpdateData(); p_rsSupplier->PutCollect(_variant_t("Suppliername",_variant((LPCTSTR)m_strName); p_rsSupplier->PutCollect....suppierID); p_rsSupplier->MoveNext(); RefreshSupplier(); } void MyView::DeleteSupplier() { if(p_rsSupplier->BOFILE || p_rsSupplier->EOFILE) { if(Warning MSgBx ==YES) { p_rsSupplier->Delete(adAffectCurrent); p_rsSupplier->MovePrevious(); RefreshSupplier(); }

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups