![]() | ![]() Products ![]() ![]() ![]() ![]() |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB Extensions » View Thread |
Messages 1 to 2 of 2 total |
![]() |
Tue, Sep 2 2008 8:26 AM | Permanent Link |
Roy Lambert NLH Associates ![]() | As I just reminded someone truncation is also needed.
unit nlhTable; interface uses SysUtils, Classes, DB, edbcomps; type TnlhTable = class(TEDBTable) private { Private declarations } FRTrimStrings: boolean; FTruncate: boolean; FNullEmptyStrings: boolean; protected { Protected declarations } procedure InternalPost; override; public { Public declarations } constructor Create(AOwner: TComponent); override; published { Published declarations } property RTrimStrings: boolean read FRTrimStrings write FRTrimStrings; property Truncate: boolean read FTruncate write FTruncate; property NullEmptyStrings: boolean read FNullEmptyStrings write FNullEmptyStrings; end; procedure Register; implementation procedure Register; begin RegisterComponents('ElevateDB', [TnlhTable]); end; { TnlhTable } constructor TnlhTable.Create(AOwner: TComponent); begin inherited; FRTrimStrings := True; FNullEmptyStrings := True; end; procedure TnlhTable.InternalPost; var Cntr: integer; Interim: string; begin if FTruncate or FRTrimStrings or FNullEmptyStrings then begin for Cntr := 0 to Fields.Count - 1 do begin if Fields[Cntr].DataType in [ftString, ftMemo, ftFmtMemo] then begin if not Fields[Cntr].IsNull then begin if FRTrimStrings then Interim := TrimRight(Fields[Cntr].AsString); if FNullEmptyStrings then if Interim = '' then Fields[Cntr].Clear else Fields[Cntr].AsString := Interim; if FTruncate and (Fields[Cntr].DataType = ftString) and (Length(Interim) > Fields[Cntr].Size) then Interim := Copy(Interim, 1, Fields[Cntr].Size); end; end else if Fields[Cntr].DataType in [ftBlob, ftGraphic] then begin if (not Fields[Cntr].IsNull) and FNullEmptyStrings and (Fields[Cntr].AsString = '') then Fields[Cntr].Clear; end; end; end; inherited; end; end. Roy Lambert |
Tue, Sep 2 2008 8:40 AM | Permanent Link |
Roy Lambert NLH Associates ![]() | Just ignore this one - I keep forgetting that TDataSet does the truncation
Roy Lambert |
This web page was last updated on Wednesday, August 14, 2024 at 07:31 PM | Privacy Policy![]() © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? ![]() |