连接用TDatabase,有方法的 void __fastcall TForm1::ApplyButtonClick(TObject *Sender){ Database1->StartTransaction(); try { CustomerQuery->ApplyUpdates(); // try to write the updates to the database Database1->Commit(); // on success, commit the changes; } catch (...) { Database1->Rollback(); // on failure, undo the changes throw; // throw the exception to prevent a call to CommitUpdates! } CustomerQuery->CommitUpdates(); // on success, clear the cache }
void __fastcall TForm1::ApplyButtonClick(TObject *Sender){
Database1->StartTransaction();
try
{
CustomerQuery->ApplyUpdates(); // try to write the updates to the database
Database1->Commit(); // on success, commit the changes;
}
catch (...)
{
Database1->Rollback(); // on failure, undo the changes
throw; // throw the exception to prevent a call to CommitUpdates!
}
CustomerQuery->CommitUpdates(); // on success, clear the cache
}
try
...
database1.Commit;
except
database1.rollback;
end;
StartTransaction;
try
...
Commit;
except
rollback;
end;