Insert, Update Sql

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Tumbe
Posts: 2
Joined: Sun 25 Nov 2007 23:02

Insert, Update Sql

Post by Tumbe » Sun 25 Nov 2007 23:16

Is it true that cachedupdates only will work dataaware comp. and using Insert, edit, Post e.t.c.

I would like to the user a change to confirm all inserts and updates at one time.

If i use InsertSql and apply() i dont get the possibility to use ROLLBACK and CANCELUPDATES

MyUpdateSql1.InsertSQL.Text := 'INSERT INTO sejler (Status, Navn) '+
' VALUES ('+'''Lejer'''+', '+'''Julemanden'''+')';

will insert a new record, but its not possible to cancel or rollback

Tumbe

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Mon 26 Nov 2007 09:09

There is no possibility to rollback changes after ApplyUpdates. You can try to use transactions instead of CachedUpdates mode.

Tumbe
Posts: 2
Joined: Sun 25 Nov 2007 23:02

Post by Tumbe » Mon 26 Nov 2007 23:35

I will study the use of transaction.

So this means that MyDac works best with dataaware controls,

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Tue 27 Nov 2007 13:36

MyDAC provides similar, TDataSet compatible, interface for both developers and data-aware controls. So you can do something like this in your code (CachedUpdates is set to False):

Code: Select all

  MyConnection.StartTransaction;
  try

     // do some changes using Insert, Edit, Post, Delete methods of a TDataSet decendant component

    MyConnection.Commit;  // apply changes
  except
    MyConnection.Rollback; // discard changes
  end;

Post Reply