Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Unidirectional problem using FDQuery


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 0
Vinicius Biazzi

Posts: 1
Registered: 3/10/15
Unidirectional problem using FDQuery  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 10, 2015 5:27 AM
I try to upgrade an old app that uses a SQLDataset + DataSetProvider + ClientDataset to use firedac.

The amount of data that will be retrieved is huge, so i try to use a combination of a FDQuery + DataSetProvider + ClientDataset using the FetchOption unidirectional=True, but if i change a record and call ApplyUpdates it doesn't work.
The strange thing here is that the SQLDataset from de DBX is unidirectional as far as i know, i don't understand why i having this issue.

I create a simple program reproducing the issue, when i run the program and change a record, calling ApplyUpdates don't change de data on the database:

unit Unit1;
 
interface
 
uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, FireDAC.Stan.Intf, FireDAC.Stan.Option,
  FireDAC.Stan.Error, FireDAC.UI.Intf, FireDAC.Phys.Intf, FireDAC.Stan.Def,
  FireDAC.Stan.Pool, FireDAC.Stan.Async, FireDAC.Phys, FireDAC.Phys.FB,
  FireDAC.Phys.FBDef, FireDAC.Stan.Param, FireDAC.DatS, FireDAC.DApt.Intf,
  FireDAC.DApt, Vcl.StdCtrls, Vcl.Grids, Vcl.DBGrids, Data.DB,
  Datasnap.DBClient, Datasnap.Provider, FireDAC.Comp.DataSet,
  FireDAC.Comp.Client, FireDAC.VCLUI.Wait, FireDAC.Comp.UI;
 
type
  TForm1 = class(TForm)
    FDConnection1: TFDConnection;
    FDQuery1: TFDQuery;
    DataSetProvider1: TDataSetProvider;
    ClientDataSet1: TClientDataSet;
    DataSource1: TDataSource;
    DBGrid1: TDBGrid;
    FDGUIxWaitCursor1: TFDGUIxWaitCursor;
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
 
var
  Form1: TForm1;
 
implementation
 
{$R *.dfm}
 
procedure TForm1.FormShow(Sender: TObject);
begin
  FDConnection1.LoginPrompt := False;
  FDConnection1.Connected   := true;
 
  FDQuery1.FetchOptions.Unidirectional := true;
 
  DataSetProvider1.Options := DataSetProvider1.Options + [poPropogateChanges, poAllowCommandText];
  DataSetProvider1.DataSet := FDQuery1;
 
  ClientDataSet1.ProviderName := DataSetProvider1.Name;
  ClientDataSet1.CommandText  := 'select * from ENTERPRISE order by ID ';
  ClientDataSet1.Open;
 
  DataSource1.DataSet := ClientDataSet1;
 
  DBGrid1.DataSource := DataSource1;
  
  ClientDataSet1.Edit;
  ClientDataSet1.fieldbyName('NAME').AsString := 'Test';//Changing NAME to 'Test'
  ClientDataSet1.Post;
 
  ClientDataSet1.ApplyUpdates(0);//no errors, no messages
 
  ClientDataSet1.Close;
  ClientDataSet1.Open;//Name still the old one
end;
 
end.
 


The question is, how can i use a clientdataset with a unidirectional dataset on the provider using the firedac tecnology that allows me to change the records?
Am i doing something Wrong?

Forgive my horrible english.
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02