curious error with dbgrid and virtual dataset with blob field

Discussion of open issues, suggestions and bugs regarding Virtual Data Access Components for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
renewitt
Posts: 1
Joined: Wed 26 Aug 2020 07:11

curious error with dbgrid and virtual dataset with blob field

Post by renewitt » Wed 26 Aug 2020 07:36

Hey there,

we use TVirtualDataSet with blob field and when I use VirtualDataSet.Append and click back in the grid, after the 4th click I get an Error "ungültige typumwandlung" or something like "invalid cast".

When we add a Blob-Field in the VirtualDataSetDemo Project we get an similar error.

There is a short video and demo project so you can see what's going on there.

Video - mp4
https://www.rene-witt.de/data/files_for ... ataset.mp4

Video - AVI
https://www.rene-witt.de/data/files_for ... ataset.avi

Demo Project
http://rene-witt.de/data/files_for_erro ... lobVDS.zip

Code

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
begin
  inherited;

  fData_List  := TObjectList<TMyData>.Create;

  fData_List.Add(TMyData.Create('Foo', 'Blaaa'));
  fData_List.Add(TMyData.Create('Bar', 'Blubb'));

  VirtualDataSet1.FieldDefs.Add('title', ftString, 125);
  VirtualDataSet1.FieldDefs.Add('description', ftBlob);

  VirtualDataSet1.OnGetRecordCount := vdMAND_WWS_PROJEKT_AUFGABE_Data_ListGetRecordCount;
  VirtualDataSet1.OnGetFieldValue  := vdMAND_WWS_PROJEKT_AUFGABE_Data_ListGetFieldValue;

  VirtualDataSet1.Open;
end;

Code: Select all

procedure TForm1.btnNewClick(Sender: TObject);
begin
  VirtualDataSet1.Append;
end;

Code: Select all

procedure TForm1.vdMAND_WWS_PROJEKT_AUFGABE_Data_ListGetFieldValue(Sender : TObject; Field : TField; RecNo : Integer; out Value : Variant);
var
  lData       : TMyData;
  lFieldName  : String;
begin
  Value := Null;

  if Not Assigned(fData_List) then
    Exit;
  if RecNo>fData_List.Count then
    Exit;

  lData := fData_List.Items[RecNo-1];

  if Not Assigned(lData) then
    Exit;

  lFieldName  := LowerCase(Field.FieldName);

  if lFieldName='title' then
    Value := lData.Title
  else if lFieldName='description' then
    Value := lData.Description
    ;
end;

Code: Select all

procedure TForm1.vdMAND_WWS_PROJEKT_AUFGABE_Data_ListGetRecordCount(Sender : TObject; out Count : Integer);
begin
  Count := 0;

  if Not Assigned(fData_List) then
    Exit;

  Count := fData_List.Count;
end;

I hope you can help us.

Best regards

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

Re: curious error with dbgrid and virtual dataset with blob field

Post by MaximG » Mon 31 Aug 2020 20:30

Thank you for the information. We will investigate the described issue and let you know the results shortly.

Post Reply