[Gambas-user] Use of db.Begin, db.Commit and db.Rollback with a datasource and datacontrols
Lewis Balentine
lewis at ...3412...
Tue Jan 20 21:37:00 CET 2015
Nope, you did not mislead me ....
I was already been looking at these methods, but I had only tried the
update function on a dataview control where the data was modified by an
external program (that works nicely).
I believe that I have tried every combination of: DataSource.Cancel,
DataSource1.Update, DataSource1.Refresh
BINGO!!
Put "DataSource.Connection.begin" just after the DB/Table is opened.
Put "DataSource.Connection.commit" and "DataSource.Connection.begin" at
the end of each save.
Use "DataSource.Connection.Rollback", "DataSource.Update",
"DataSource.Connection.Begin" to cancel.
Alas I have run out of time and must attend to other matters.
I will try update my example tomorrow and upload it.
(I also want a bit more testing).
Regards,
Lewis
On 01/20/2015 01:07 PM, T Lee Davidson wrote:
> I believe I have mislead you too, Lewis. My apologies.
>
> Look at DataSource.Update.
>
>
> Lee
> __________
>
> "Artificial Intelligence is no match for natural stupidity."
>
> On 01/20/2015 01:03 PM, Lewis Balentine wrote:
>> 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
>>> __________
>>>
>>
>>
>> ------------------------------------------------------------------------------
>> 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
>>
> ------------------------------------------------------------------------------
> 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