Subject | Re: [IBO] How to encrypt/decrypt during a query or before actually showing data? |
---|---|
Author | Markus Ostenried |
Post date | 2005-01-25T21:24:43Z |
At 12:56 Tuesday, 25.01.2005 -0800, Chuck Belanger wrote:
since IBO odesn't have persistent fields you have to remember the field
objects yourself:
type
DataModule1 = class( TDataModule )
IB_Query1: TIB_Query;
procedure IB_Query1AfterPrepare( Sender: TIB_Statement );
procedure IB_Query1BeforeUnPrepare( Sender: TIB_Statement );
private
Field1: TIB_Column;
procedure Field1OnSetText( Sender: TIB_Column; var AValue: String );
end;
implementation
procedure TDataModule1.IB_Query1AfterPrepare( Sender: TIB_Statement );
begin
Field1 := IB_Query1.FieldByName( 'Field1' );
Field1.OnGet := Field1OnGet;
end;
procedure TDataModule1.IB_Query1BeforeUnPrepare( Sender: TIB_Statement );
begin
Field1 := nil;
end;
procedure TDataModule1Field1OnSetText( Sender: TIB_Column; var AValue:
String );
begin
// do encrypt here ...
end;
And if you only want to decrypt and show data then you can use a calculated
field for it and decrypt your data in the OnCalculateFields event.
HTH,
markus
>So, I found that IB_Query.FieldByName(asString).OnSET/GETText exist asHi,
>an event of TIB_Column and that this is the equivalent of TField. But
>how do I access and create a encryption/decryption routine in these
>events? Any examples on how to use these events, especially for what I'm
>trying to do?
since IBO odesn't have persistent fields you have to remember the field
objects yourself:
type
DataModule1 = class( TDataModule )
IB_Query1: TIB_Query;
procedure IB_Query1AfterPrepare( Sender: TIB_Statement );
procedure IB_Query1BeforeUnPrepare( Sender: TIB_Statement );
private
Field1: TIB_Column;
procedure Field1OnSetText( Sender: TIB_Column; var AValue: String );
end;
implementation
procedure TDataModule1.IB_Query1AfterPrepare( Sender: TIB_Statement );
begin
Field1 := IB_Query1.FieldByName( 'Field1' );
Field1.OnGet := Field1OnGet;
end;
procedure TDataModule1.IB_Query1BeforeUnPrepare( Sender: TIB_Statement );
begin
Field1 := nil;
end;
procedure TDataModule1Field1OnSetText( Sender: TIB_Column; var AValue:
String );
begin
// do encrypt here ...
end;
And if you only want to decrypt and show data then you can use a calculated
field for it and decrypt your data in the OnCalculateFields event.
HTH,
markus