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. General Programming
  3. C / C++ / MFC
  4. Edit a record in a DB table opened with ODBC

Edit a record in a DB table opened with ODBC

Scheduled Pinned Locked Moved C / C++ / MFC
questiondatabasehelpannouncement
2 Posts 2 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.
  • S Offline
    S Offline
    sirtimid
    wrote on last edited by
    #1

    I open the table and I search in it row by row as follows: TableSet->Open(); TableSet->MoveFirst(); while(!TableSet->IsEOF()) { if(TableSet->m_field1 == id) { TableSet->Edit(); TableSet->m_field2 += 10; TableSet->Update(); } else { TableSet->MoveNext(); } } The problem is that when the program goes in the if statement (the row has been found), and it is the first row of the table, the update operation returns: 'No rows where affected by the update or delete operation' If this is not the first row the update operation success. Does anyone know why does this happen? Thanks in advance sirtimid

    D 1 Reply Last reply
    0
    • S sirtimid

      I open the table and I search in it row by row as follows: TableSet->Open(); TableSet->MoveFirst(); while(!TableSet->IsEOF()) { if(TableSet->m_field1 == id) { TableSet->Edit(); TableSet->m_field2 += 10; TableSet->Update(); } else { TableSet->MoveNext(); } } The problem is that when the program goes in the if statement (the row has been found), and it is the first row of the table, the update operation returns: 'No rows where affected by the update or delete operation' If this is not the first row the update operation success. Does anyone know why does this happen? Thanks in advance sirtimid

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      This seems very inefficient. Rather than iterate through each row of the table, why not use a WHERE clause so that the recordset only contains the row(s) that need(s) updating?


      "One must learn from the bite of the fire to leave it alone." - Native American Proverb

      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