TDataSetProvider X TMyQuery

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
RNOVAK
Posts: 26
Joined: Sat 19 Feb 2011 18:30
Contact:

TDataSetProvider X TMyQuery

Post by RNOVAK » Thu 07 Aug 2014 16:56

(My question is similar to question 2 on http://forums.devart.com/viewtopic.php?t=21443)

I have TClientDataSet + TDataSetProvider + TMyQuery

I apply Changes as ...

Code: Select all

  MyClientDataSet1.Open; ...
  MyClientDataSet1.Delete; ...
  ...
  MyConn.StartTransaction;
    MyDataSetProvider1.ApplyUpdates(MyClientDataSet1.Delta, 0, myTransactionErrorCount);
    ...
    here I want to know RowsAffected but not working... 
    (if I have at least 1 deleted record so must shows 1 record affected)
    ...
  MyConn.Commit and MergeChangeLog to all ClientDataSets or Rollback all;
To intercept and see RowsAffected I am doing:
on MyDataSetProvider1.AfterApplyUpdates, p example:

Code: Select all

ShowMessage(IntToStr(TMyQuery((Sender as TDataSetProvider).DataSet).RowsAffected));
but RowsAffected returning '-1' always.

How to use this way with TMyQuery ?

Well, is possible to do this way (with 'SELECT ROW_COUNT')
...

Code: Select all

  MyConn.StartTransaction;
    MyDataSetProvider1.ApplyUpdates(MyClientDataSet1.Delta, 0, myTransactionErrorCount);
      qu.SQL.Text := 'SELECT ROW_COUNT();';
      qu.Open;
      myAffectedRows := qu.Fields[0].AsString;
      qu.Close;
    ...
  MyConn.Commit and MergeChangeLog to all ClientDataSets or Rollback all;

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

Re: TDataSetProvider X TMyQuery

Post by ViktorV » Fri 08 Aug 2014 12:09

As you use TClientDataset, TDataSetProvider makes all changes. Not TMyQuery.
TMyQuery doesn't change, therefore RowsAffected return '-1'.

You can set the TMyDataSetProvider.ResolveToDataSet property to True.
Then TMyQuery will make all changes and RowsAffected will return a correct value.

RNOVAK
Posts: 26
Joined: Sat 19 Feb 2011 18:30
Contact:

Re: TDataSetProvider X TMyQuery

Post by RNOVAK » Mon 11 Aug 2014 18:49

Thank You !
Works fine

Post Reply