Edit a record in a DB table opened with ODBC
-
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
-
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
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