Page 1 of 1
auto commit property?
Posted: Tue 28 Apr 2009 20:30
by dragonstar
I'm looking in the help file and it says both MyConnection and MyQuery are supposed to have an AutoCommit property.
They aren't listed in the object inspector and when I try and set them in code I get unknown identifier.
So which is right? There's is or isn't supposed to be such a property?
And if not where the help says, where is the mechanism for enabling auto commit for inserts, updates, deletes, etc.?
drc

Posted: Thu 30 Apr 2009 10:11
by Dimon
TMyConnection and TMyQuery components don't have the AutoCommit property. If you change data (e.g., insert, update, delete), it is saved in a database automaticly on calling the Post method, unless you use transactions. But if you execute the StartTransaction method, then to save data to a database, execute the Commit method.
works for me...
Posted: Thu 30 Apr 2009 17:13
by dragonstar
Got it. But it'd be nice if the help was accurate, as in not mentioning properties that don't exist.
And what about a Query whose sql is an update statement? No Post method for that just Execute, anything else have to be called to get the changes to commit?
drc

Posted: Thu 30 Apr 2009 18:37
by swierzbicki
And what about a Query whose sql is an update statement? No Post method for that just Execute, anything else have to be called to get the changes to commit?
It's the same !
All modifications done to the database will be saved when commit method will be called (or cancelled if rollback method is called).
Exemple :
Code: Select all
MyConnection.StartTransaction;
Try
//....(update, insert delete anything you want)
MyConnection.Commit;
Except
//...an error occured, rolling back modifications
MyConnection.Rollback;
End;