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

Lewis Balentine lewis at ...3412...
Tue Jan 20 19:03:42 CET 2015


Mr. Speaker,
I request permission to revise and extend my previous remarks ...

Please see the attached sample application and data base. I used a 
SQlite Database but in theory these function should operate the same. I 
tried five ways to cancel the edits to a set of data controls.
     via Control Refresh
     via Data Source Refresh
     via Data Source Cancel
     via Closing the DB and reopening it
     via Data Control Tags

The only one that I found that worked was to restore the content from a 
copy saved in the data control tags. I note that changing the 
'DataControl.Value' (either via software or manually) does not set 
'DataSource.Modified' or "DataControl.Modified' properties to true. The 
operation was the same in version 3.6.2 and 3.6.9.

Then again maybe I am doing something(s) wrong .... :-\

Regards,

Lewis Balentine

On 01/19/2015 07:42 PM, T Lee Davidson wrote:
> 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
> __________
>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: DBSample-0.0.1.tar.gz
Type: application/gzip
Size: 7941 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20150120/13423202/attachment.gz>


More information about the User mailing list