TVirtualDataSet - TGuidField Error

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
leonardt.neugebauer
Posts: 32
Joined: Wed 27 May 2020 06:22

TVirtualDataSet - TGuidField Error

Post by leonardt.neugebauer » Mon 19 Apr 2021 15:29

Hello with version 8.4.3 there is a problem with the VirtualDataSets and TGUIDFields.
When I have more than one GUIDField in the DataSet, the last character in some field is displayed wrong.
The brace at the end is displayed incorrectly.

Code: Select all

unit Unit56;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Data.DB, MemDS, VirtualDataSet,
  Vcl.Grids, Vcl.DBGrids, DBAccess, Uni, System.Generics.Collections;

type
  TGUIDClass = class
    GUID1: TGUID;
    GUID2: TGUID;
  end;

  TForm56 = class(TForm)
    VirtualDataSet1: TVirtualDataSet;
    gfGUID1: TGuidField;
    gfGUID2: TGuidField;
    UniDataSource1: TUniDataSource;
    DBGrid1: TDBGrid;
    procedure FormDestroy(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure VirtualDataSet1GetFieldValue(Sender: TObject; Field: TField; RecNo:
        Integer; out Value: Variant);
    procedure VirtualDataSet1GetRecordCount(Sender: TObject; out Count: Integer);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
    FGUIDList : TObjectList<TGUIDClass>;
  end;

var
  Form56: TForm56;

implementation

{$R *.dfm}

procedure TForm56.FormDestroy(Sender: TObject);
begin
 FreeAndNil( FGUIDList);
end;

procedure TForm56.FormCreate(Sender: TObject);
begin
 FGUIDList := TObjectList<TGUIDClass>.Create( True);
 for var i := 0 to 10 do
 begin
  var lGUIDObject := TGUIDClass.Create;
  lGUIDObject.GUID1 := TGUID.NewGuid;
  lGUIDObject.GUID2 := TGUID.NewGuid;
  FGUIDList.Add( lGUIDObject);
 end;
 VirtualDataSet1.Open;
end;

procedure TForm56.VirtualDataSet1GetFieldValue(Sender: TObject; Field: TField;
    RecNo: Integer; out Value: Variant);
begin
// If I leave only one of the fields in it is displayed correctly, no matter which field
 case Field.Index of
  0: Value := FGUIDList[ RecNo-1].GUID1.ToString;
  1: Value := FGUIDList[ RecNo-1].GUID2.ToString;
 end;
end;

procedure TForm56.VirtualDataSet1GetRecordCount(Sender: TObject; out Count:
    Integer);
begin
 Count := FGUIDList.Count;
end;

end.

leonardt.neugebauer
Posts: 32
Joined: Wed 27 May 2020 06:22

Re: TVirtualDataSet - TGuidField Error

Post by leonardt.neugebauer » Mon 19 Apr 2021 15:41

I think the problem is with the conversion from TGUID to string.
If you use the ToString from TGUIDHelper it works without problems.
With version 8.3.2 everything worked without problems.
See example:

Code: Select all

procedure TForm56.DBGrid1CellClick(Column: TColumn);
begin
 ShowMessage( 'Field-GUID1 | Value: ' + gfGUID1.Value + sLineBreak + //wrong
              'Field-GUID1 | AsGuid.ToString: ' + gfGUID1.AsGuid.ToString + sLineBreak + //correct
              'Field-GUID1 | AsString: ' + gfGUID1.AsString + sLineBreak +//wrong
              'FGUIDList-GUID1 | ToString: ' + FGUIDList[ VirtualDataSet1.RecNo-1].GUID1.ToString); //correct
end;

Stellar
Devart Team
Posts: 496
Joined: Tue 03 Oct 2017 11:00

Re: TVirtualDataSet - TGuidField Error

Post by Stellar » Tue 01 Jun 2021 08:16

Thank you for providing the information. We've reproduced the issue and started to investigate possible causes of the described behavior. We will let you know the results as soon as we get them.

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: TVirtualDataSet - TGuidField Error

Post by MaximG » Fri 16 Jul 2021 09:33

We've reproduced the issue and fixed it. The new version of VirtualDAC that contains the fix is already available for download on our website.

Post Reply