UniDAC Connection Autocommit False not working

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
mirkocutri
Posts: 10
Joined: Mon 15 Feb 2016 22:54

UniDAC Connection Autocommit False not working

Post by mirkocutri » Tue 16 Feb 2016 00:02

Hi.
I work with this settings:
UniConnection.AutoCommit = false
UniQuery.Connection = UniConnection
UniQuery.Transaction = <default> (no specific UniTransaction in this application)
UniQuery.DefaultCloseAction = taRollback (don't think this matters here)

When I edit a value and scroll to next or prior with a navigator row without posting, the database is still updated. How can I avoid this behaviour? On scrolling without posting changes should not be posted or give a message to post or discard changes.

Thanks a lot for your help
M.

azyk
Devart Team
Posts: 1119
Joined: Fri 11 Apr 2014 11:47
Location: Alpha Centauri A

Re: UniDAC Connection Autocommit False not working

Post by azyk » Tue 16 Feb 2016 08:04

Please specify the database you are working with.

mirkocutri
Posts: 10
Joined: Mon 15 Feb 2016 22:54

Re: UniDAC Connection Autocommit False not working

Post by mirkocutri » Tue 16 Feb 2016 22:12

Ups, sorry... MySQL

:)

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: UniDAC Connection Autocommit False not working

Post by ViktorV » Wed 17 Feb 2016 11:39

Working with MySQL server, the TUniConnection.AutoCommit property is not used. If you change data (e.g., insert, update, delete), it is always saved in a database automatically on calling the Post method, unless you use transactions. When using DB controls, if the dataset is in the edit mode, on navigating through records, the Post method is automatically executed. To commit or cancel changes, you can use the BeforePost event handler. For example:

Code: Select all

procedure TForm1.UniQueryBeforePost(DataSet: TDataSet);
begin
  if (MessageDlg('Save changes?', mtConfirmation, [mbOk, mbCancel], 0) = mrCancel) then
    DataSet.Cancel;
end;

mirkocutri
Posts: 10
Joined: Mon 15 Feb 2016 22:54

Re: UniDAC Connection Autocommit False not working

Post by mirkocutri » Thu 18 Feb 2016 07:05

It's working fine now.... thank you very much for the tipp about MySQL behaviour on AutoCommit :D

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: UniDAC Connection Autocommit False not working

Post by ViktorV » Thu 18 Feb 2016 14:17

It is good to see that the problem has been solved. Feel free to contact us if you have any further questions about IBDAC.

Post Reply