Board index » delphi » TDataset.UpdateRecord Doesn 't work for me ?!?

TDataset.UpdateRecord Doesn 't work for me ?!?

Hi,

Maybe I got this wrong but my understanding of the UpdateRecord Procedure is
to allow for the verification of each record before they are posted to the
Database in a TQuery or TTable when Cached Updates is set to True.

Now I have code here that I think would work but it doesn't if you know why
let me know.  There are no Delphi Exemple provided and the Delphi Help is
very limmited.

procedure TDM_TransMonitor.Query1UpdateRecord(
  DataSet: TDataSet; UpdateKind: TUpdateKind;
  var UpdateAction: TUpdateAction);
begin
  If DataSet.FieldByName('RECORDID').AsString = '24'
  Then Begin
    UpdateAction := uaApplied ;
  End
  Else UpdateAction := uaSkip ;
end;

This code goes down the If Then Branch and it doesn't depending on the
condition.  Thsi part works.  What doesn't is that I does nothing!   All the
record yout a RecordID of 24 stays in the Query same as the other record
with a recordID other than 24.

Am I supposed to do something to actually write the data to the Database ?
what Am I doing wrong?

eric
ejod...@inetex.com

 

Re:TDataset.UpdateRecord Doesn 't work for me ?!?


Hi,

If you write code to TDataSet.UpdateRecord event you must exclict call
a TUpdateSQL.ExecSQL statment, like this:

procedure TForm1.TabUpdateRecord(DataSet: TDataSet;
  UpdateKind: TUpdateKind; var UpdateAction: TUpdateAction);
begin
  UpdateSQL1.DataSet := DataSet;
  UpdateSQL1.ExecSQL(UpdateKind);
 UpdateAction := uaApplied;
end;

I Hope this help you,

Marcos Tito
t...@gold.com.br

Quote
Eric wrote in message <6p6nvs$o...@forums.borland.com>...
>Hi,

>Maybe I got this wrong but my understanding of the UpdateRecord Procedure
is
>to allow for the verification of each record before they are posted to the
>Database in a TQuery or TTable when Cached Updates is set to True.

>Now I have code here that I think would work but it doesn't if you know why
>let me know.  There are no Delphi Exemple provided and the Delphi Help is
>very limmited.

>procedure TDM_TransMonitor.Query1UpdateRecord(
>  DataSet: TDataSet; UpdateKind: TUpdateKind;
>  var UpdateAction: TUpdateAction);
>begin
>  If DataSet.FieldByName('RECORDID').AsString = '24'
>  Then Begin
>    UpdateAction := uaApplied ;
>  End
>  Else UpdateAction := uaSkip ;
>end;

>This code goes down the If Then Branch and it doesn't depending on the
>condition.  Thsi part works.  What doesn't is that I does nothing!   All
the
>record yout a RecordID of 24 stays in the Query same as the other record
>with a recordID other than 24.

>Am I supposed to do something to actually write the data to the Database ?
>what Am I doing wrong?

>eric
>ejod...@inetex.com

Other Threads