[Gambas-user] Use of db.Begin, db.Commit and db.Rollback with a datasource and datacontrols

T Lee Davidson t.lee.davidson at ...626...
Tue Jan 20 02:42:19 CET 2015


Hello Martin,

If you are working with only one record at a time, you don't need to use transactions.
Transactions are used when multiple records need to be modified in an all-or-none scenario, such as when a record, that is the "one" in a 
one-to-many relationship, needs to be deleted.

In such a case, you would start a transaction with .Begin, delete the dependent records followed by the one record. Then, if all modifications 
are successful, you would .Commit. If there is a failure at any time during the transaction, you would .Rollback.

To get the datacontrol to display the original data after a canceled edit, use the .Refresh method.


Lee
__________

"Artificial Intelligence is no match for natural stupidity."

On 01/19/2015 07:11 PM, Martin McGlensey wrote:
> Hello,
>
>
>
> I have a form containing a datasource linked to a MySQL database table. The
> datasource contains datacontrols to display the data from the underlying
> table. There are buttons for add, edit, save, delete and cancel. The add
> button creates a new record. The save button saves the record. The Edit
> button allows change to the record. The cancel button cancels the changes.
> The delete button deletes the entire record.
>
>
>
> I would like the cancel button to cancel the add and all edits and
> repopulate the form with the original data from the datasource table. If the
> user hits the cancel button no change should be made to the table. The
> delete button asks for confirmation before deleting the record.
>
>
>
> I'm not so much looking for code so much but for advice on the proper
> sequence of bd.begin etc. Should add and edit begin a transaction and save
> commit the transaction? Should cancel rollback the transaction? The syntax
> is $Con.Begin, $Con.Commit and $Con.Rollback. Is that correct? If my thought
> is correct how do I get the form to display the original data?
>
>
>
> Thanks
>
> ------------------------------------------------------------------------------
> New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
> GigeNET is offering a free month of service with a new server in Ashburn.
> Choose from 2 high performing configs, both with 100TB of bandwidth.
> Higher redundancy.Lower latency.Increased capacity.Completely compliant.
> http://p.sf.net/sfu/gigenet
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>




More information about the User mailing list