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. ODBC and CRecordSet::Update

ODBC and CRecordSet::Update

Scheduled Pinned Locked Moved Database
helpannouncement
2 Posts 2 Posters 4 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.
  • E Offline
    E Offline
    Eric MILLAUD
    wrote on last edited by
    #1

    Hi When i use the function CRecordSet::Update, i have an exception. Besides, when i use the function Crecordset::MoveFirst, I don't read the first record. Anyone can help me please. I send you my code. Thanks try { /* APP->m_TmSet -> Open ();*/ CTmSet tmset; if (tmset.IsOpen () ) tmset.Close () ; tmset.Open(); MessageBox(NULL,"passe","passe3",MB_OK); //if ( APP->m_TmSet -> CanAppend () ) if (tmset.CanAppend () ) { MessageBox(NULL,"avant new","passe",MB_OK); //tmset.AddNew(); tmset.MoveFirst(); tmset.Requery () ; //tmset.Edit(); for (int n=0;n<20;n++) { char buf[10]; MessageBox(NULL,tmset.m_TM_NAME,"nom",MB_OK); wsprintf(buf,"%ld",tmset.m_TM_ID); MessageBox(NULL,buf,"id",MB_OK); tmset.MoveNext(); } int a=tmset.GetRecordCount(); wsprintf(buf,"%ld",a); MessageBox(NULL,buf,"nb record",MB_OK); /*tmset.m_BAY_CODE =TmSql->numBay ; tmset.m_TM_ID =TmSql->numTm ; tmset. m_TM_NAME=TmSql->libTm ; tmset.m_TM_UNIT =TmSql->libUnit; tmset.m_TM_ARCHIVE =TmSql->FlgArchive ; tmset.m_TM_STATE_CURRENT =0; tmset.m_TM_DATE_CURRENT =0 ; tmset.m_TM_DATE_OK_CURRENT=0 ;*/ tmset.m_BAY_CODE =0 ; tmset.m_TM_ID =0 ; tmset. m_TM_NAME="a" ; tmset.m_TM_UNIT ="b"; tmset.m_TM_ARCHIVE =0 ; tmset.m_TM_STATE_CURRENT =0; tmset.m_TM_DATE_CURRENT =0 ; tmset.m_TM_DATE_OK_CURRENT=0 ; if (tmset.CanUpdate () !=0) { MessageBox(NULL,"avant Update ","passe",MB_OK); tmset.Update(); MessageBox(NULL,"après Update","passe",MB_OK); } if ( tmset.IsEOF ()!=0 ) tmset.MoveLast (); tmset.Requery () ; tmset.MoveLast () ; MessageBox(NULL,"ajoute3","passe",MB_OK); // UpdateData ( FALSE ) ; } else AfxMessageBox ( "Can Not Append a Record" ) ; } catch( CDBException* e ) { AfxMessageBox( e->m_nRetCode, MB_ICONEXCLAMATION ); // Delete the incomplete recordset object /* delete m_pSet; m_pSet = NULL;*/ e->Delete(); }

    R 1 Reply Last reply
    0
    • E Eric MILLAUD

      Hi When i use the function CRecordSet::Update, i have an exception. Besides, when i use the function Crecordset::MoveFirst, I don't read the first record. Anyone can help me please. I send you my code. Thanks try { /* APP->m_TmSet -> Open ();*/ CTmSet tmset; if (tmset.IsOpen () ) tmset.Close () ; tmset.Open(); MessageBox(NULL,"passe","passe3",MB_OK); //if ( APP->m_TmSet -> CanAppend () ) if (tmset.CanAppend () ) { MessageBox(NULL,"avant new","passe",MB_OK); //tmset.AddNew(); tmset.MoveFirst(); tmset.Requery () ; //tmset.Edit(); for (int n=0;n<20;n++) { char buf[10]; MessageBox(NULL,tmset.m_TM_NAME,"nom",MB_OK); wsprintf(buf,"%ld",tmset.m_TM_ID); MessageBox(NULL,buf,"id",MB_OK); tmset.MoveNext(); } int a=tmset.GetRecordCount(); wsprintf(buf,"%ld",a); MessageBox(NULL,buf,"nb record",MB_OK); /*tmset.m_BAY_CODE =TmSql->numBay ; tmset.m_TM_ID =TmSql->numTm ; tmset. m_TM_NAME=TmSql->libTm ; tmset.m_TM_UNIT =TmSql->libUnit; tmset.m_TM_ARCHIVE =TmSql->FlgArchive ; tmset.m_TM_STATE_CURRENT =0; tmset.m_TM_DATE_CURRENT =0 ; tmset.m_TM_DATE_OK_CURRENT=0 ;*/ tmset.m_BAY_CODE =0 ; tmset.m_TM_ID =0 ; tmset. m_TM_NAME="a" ; tmset.m_TM_UNIT ="b"; tmset.m_TM_ARCHIVE =0 ; tmset.m_TM_STATE_CURRENT =0; tmset.m_TM_DATE_CURRENT =0 ; tmset.m_TM_DATE_OK_CURRENT=0 ; if (tmset.CanUpdate () !=0) { MessageBox(NULL,"avant Update ","passe",MB_OK); tmset.Update(); MessageBox(NULL,"après Update","passe",MB_OK); } if ( tmset.IsEOF ()!=0 ) tmset.MoveLast (); tmset.Requery () ; tmset.MoveLast () ; MessageBox(NULL,"ajoute3","passe",MB_OK); // UpdateData ( FALSE ) ; } else AfxMessageBox ( "Can Not Append a Record" ) ; } catch( CDBException* e ) { AfxMessageBox( e->m_nRetCode, MB_ICONEXCLAMATION ); // Delete the incomplete recordset object /* delete m_pSet; m_pSet = NULL;*/ e->Delete(); }

      R Offline
      R Offline
      Rashid Thadha
      wrote on last edited by
      #2

      You need to call AddNew or Edit Methods before you call Update. Your code currently has them commented out.

      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