🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.delphi.database.win32
3 messages
3 total messages Started by Devinder Singh Sun, 26 Aug 2007 14:16
New record Event on the Fly
#103
Author: Devinder Singh
Date: Sun, 26 Aug 2007 14:16
26 lines
1641 bytes
I am creating a ClientDataset on the fly and want to assign a onNewRecord
event to the table.

  Table := TClientDataSet.Create(Self);
  Table.FieldDefs.Add('COMPCODE'   ,ftInteger);
  Table.FieldDefs.Add('COMPYRCODE' ,ftInteger);
  Table.FieldDefs.Add('NARR'       ,ftString);
  Table.FieldDefs.Add('PMTMODE'    ,ftString);
  Table.OnNewRecord := NewRecord;  // Here
  Table.CreateDataSet;

procedure NewRecord;
begin
  Table.FieldByName('COMPCODE').Value := 1;
  Table.FieldByName('COMPYRCODE').Value :=
AllData.SessionCOMPYRCODE.AsInteger;
  Table.FieldByName('VCHDATE').Value := DataDATED.AsVariant;
  Table.FieldByName('TRNTYPE').Value := 'MAT';
  Table.FieldByName('INVNO').Value := DataINVNO.AsVariant;
end;

What's the right way of doing it.

regards

Devinder
Re: New record Event on the Fly
#104
Author: yannis
Date: Mon, 27 Aug 2007 08:12
37 lines
2137 bytes
After serious thinking Devinder Singh wrote :
> I am creating a ClientDataset on the fly and want to assign a onNewRecord
> event to the table.
>
>   Table := TClientDataSet.Create(Self);
>   Table.FieldDefs.Add('COMPCODE'   ,ftInteger);
>   Table.FieldDefs.Add('COMPYRCODE' ,ftInteger);
>   Table.FieldDefs.Add('NARR'       ,ftString);
>   Table.FieldDefs.Add('PMTMODE'    ,ftString);
>   Table.OnNewRecord := NewRecord;  // Here
>   Table.CreateDataSet;
>
> procedure NewRecord;
> begin
>   Table.FieldByName('COMPCODE').Value := 1;
>   Table.FieldByName('COMPYRCODE').Value :=
> AllData.SessionCOMPYRCODE.AsInteger;
>   Table.FieldByName('VCHDATE').Value := DataDATED.AsVariant;
>   Table.FieldByName('TRNTYPE').Value := 'MAT';
>   Table.FieldByName('INVNO').Value := DataINVNO.AsVariant;
> end;
>
> What's the right way of doing it.
>
> regards
>
> Devinder

OnNewRecord is defined as procedure(DataSet: TDataSet) of object. The 
"of object" informs the compiler that the event handler must be a 
method of an object. This meens that you can't passed to it any 
procedure you want. Make sure tha the NewProcedure Is a method of an 
object either your form/Datamodule you use to place the ClientDataset 
or a new custom event object.

regards
Yannis.
Re: New record Event on the Fly
#105
Author: Devinder Singh
Date: Mon, 27 Aug 2007 14:16
44 lines
2566 bytes
Thanks, Yannis. I had that method in the private block.


"yannis" <none@noware.non> wrote in message 
news:mn.daa07d784c3553a1.0@noware.non...
> After serious thinking Devinder Singh wrote :
>> I am creating a ClientDataset on the fly and want to assign a onNewRecord
>> event to the table.
>>
>>   Table := TClientDataSet.Create(Self);
>>   Table.FieldDefs.Add('COMPCODE'   ,ftInteger);
>>   Table.FieldDefs.Add('COMPYRCODE' ,ftInteger);
>>   Table.FieldDefs.Add('NARR'       ,ftString);
>>   Table.FieldDefs.Add('PMTMODE'    ,ftString);
>>   Table.OnNewRecord := NewRecord;  // Here
>>   Table.CreateDataSet;
>>
>> procedure NewRecord;
>> begin
>>   Table.FieldByName('COMPCODE').Value := 1;
>>   Table.FieldByName('COMPYRCODE').Value :=
>> AllData.SessionCOMPYRCODE.AsInteger;
>>   Table.FieldByName('VCHDATE').Value := DataDATED.AsVariant;
>>   Table.FieldByName('TRNTYPE').Value := 'MAT';
>>   Table.FieldByName('INVNO').Value := DataINVNO.AsVariant;
>> end;
>>
>> What's the right way of doing it.
>>
>> regards
>>
>> Devinder
>
> OnNewRecord is defined as procedure(DataSet: TDataSet) of object. The "of 
> object" informs the compiler that the event handler must be a method of an 
> object. This meens that you can't passed to it any procedure you want. 
> Make sure tha the NewProcedure Is a method of an object either your 
> form/Datamodule you use to place the ClientDataset or a new custom event 
> object.
>
> regards
> Yannis.
>
> 
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads