Updating records using TMyQuery in Borland C++
Posted: Mon 20 Oct 2008 21:54
I'm having trouble updating a recordset using the TMyQuery object. FetchAll is True and CachedUpdate is True. My code looks like this:
MyQuery->SQL->Text= SQLstr;
MyQuery->Execute();
int rowCount= MyQuery->RecordCount;
double v = 0.0;
for(int i=0; iEdit();
v=offsetVec.at(i);
MyQuery->FieldByName("Offset")->AsFloat = v;
MyQuery->Post();
//MyQuery->ApplyUpdates();
MyQuery->Next();
}
}
//MyQuery->ApplyUpdates();
MyQuery->SQL->Clear(); Clear causes a failure.
MyQuery->Close();
offsetVex.size() does equal rowCount. This fails with a "Update failed" error on the ->Close statement. If I replace the ->AsFloat = v; with AsFloat = 99.9; then the update occurs. However, I think that this is an artifact, since if I update just the first record (replace rowCount in the loop statement by 1) all of the records are updated, although I do get an Upate Failed error on the close statement. If I do an ApplyUpdates within the loop after the Post, I also get an Update Failed Error on the ->Next statement.
How can I update the individual records of the recordset?
Thanks
MyQuery->SQL->Text= SQLstr;
MyQuery->Execute();
int rowCount= MyQuery->RecordCount;
double v = 0.0;
for(int i=0; iEdit();
v=offsetVec.at(i);
MyQuery->FieldByName("Offset")->AsFloat = v;
MyQuery->Post();
//MyQuery->ApplyUpdates();
MyQuery->Next();
}
}
//MyQuery->ApplyUpdates();
MyQuery->SQL->Clear(); Clear causes a failure.
MyQuery->Close();
offsetVex.size() does equal rowCount. This fails with a "Update failed" error on the ->Close statement. If I replace the ->AsFloat = v; with AsFloat = 99.9; then the update occurs. However, I think that this is an artifact, since if I update just the first record (replace rowCount in the loop statement by 1) all of the records are updated, although I do get an Upate Failed error on the close statement. If I do an ApplyUpdates within the loop after the Post, I also get an Update Failed Error on the ->Next statement.
How can I update the individual records of the recordset?
Thanks